Added basic logic for new slime behaviour (It now follows the player a certain distance). Changed some prefab namings

This commit is contained in:
finnchen123
2025-11-19 20:45:49 +01:00
parent a8cca74fc4
commit abc11650ee
20 changed files with 1345 additions and 159 deletions

View File

@@ -18,12 +18,19 @@ namespace Assets.Scripts.InteractableObjects
public SlimeType slimeType;
bool isJumping;
Stopwatch jumpTimer;
bool followsPlayer;
bool isAttacking;
Stopwatch attackTimer;
// Start is called before the first frame update
void Start()
{
isJumping = false;
isJumping = true;
jumpTimer = new Stopwatch();
jumpTimer.Start();
followsPlayer = false;
isAttacking = false;
attackTimer = new Stopwatch();
//Nothing
}
@@ -36,8 +43,18 @@ namespace Assets.Scripts.InteractableObjects
{
jumpTimer.Start();
isJumping = true;
gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(rand.Next(-5, 5), 10, rand.Next(-5, 5)), ForceMode.Impulse);
//gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(5, 10, 5), ForceMode.Impulse);
Vector3 jumpVector;
if (followsPlayer)
{
jumpVector = GameObject.Find("Player").transform.position - gameObject.transform.position;
jumpVector *= 0.25f * Mathf.Log10(jumpVector.magnitude);
jumpVector.y = 5;
}
else
{
jumpVector = new Vector3(rand.Next(-5, 5), 10, rand.Next(-5, 5));
}
gameObject.GetComponent<Rigidbody>().AddForce(jumpVector, ForceMode.Impulse);
}
if (jumpTimer.ElapsedMilliseconds >= 5000)
{
@@ -59,9 +76,22 @@ namespace Assets.Scripts.InteractableObjects
}
}
void OnDisable()
public void handleAttack()
{
isAttacking = true;
//Create attack logic here
}
public void handleFollow(bool isFollowing)
{
followsPlayer = isFollowing;
isAttacking = false;
//Stop attacks
}
public void handleDetection()
{
followsPlayer = true;
}
public override void handleInteraction(GameObject player)