-created a script for breakable objects

-updated block prefabs (updated size/added breakable script)
-added demo scene for blocks/breakable script
This commit is contained in:
Evan Nydahl
2021-12-07 18:35:05 -06:00
parent 5a8b657e16
commit 64b920c3d5
164 changed files with 15144 additions and 151 deletions

View File

@@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BreakableBlock : MonoBehaviour
{
//kicking power 150 (250 for stornger kick)
public float health;
// Start is called before the first frame update
void Start(){
//if health is not set, default it to 1
if(health == 0){
health = 3;
}
}
// Update is called once per frame
void Update()
{
}
public void damage(float kickPower){
int totalDamage = (int)(kickPower / 50.0);
health -= totalDamage;
Debug.Log(health);
//if item is at 0 health
if(health <= 0){
destroy();
}
}
//called once health here is zero
public void destroy(){
Destroy(this.gameObject);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5fa71751031fd4542bb5ef0d2c9672cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -41,7 +41,6 @@ public class dKickController : NetworkBehaviour
}
//otherwise do ground kick for .3 seconds
else if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false){
Debug.Log("kick");
StartCoroutine(Kicking(.3f));
}
@@ -76,6 +75,9 @@ public class dKickController : NetworkBehaviour
Debug.Log(direction);
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
}
if (collision.transform.CompareTag("destroyable") && myCollider == leg.GetComponent<Collider>()){
collision.transform.gameObject.GetComponent<BreakableBlock>().damage(pStats.KickPow);
}
}
}

View File

@@ -41,7 +41,6 @@ public class KickController : NetworkBehaviour
}
//otherwise do ground kick for .3 seconds
else if (( Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false){
Debug.Log("kick");
StartCoroutine(Kicking(.3f));
}
@@ -75,6 +74,9 @@ public class KickController : NetworkBehaviour
Debug.Log(direction);
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
}
if (collision.transform.CompareTag("destroyable") && myCollider == leg.GetComponent<Collider>()){
collision.rigidbody.gameObject.GetComponent<BreakableBlock>().damage(pStats.KickPow);
}
}
}