- Home /
Question by
DarKMaskMaster · Apr 17, 2020 at 11:30 AM ·
target
Saved Asset Enemy Flyes arount target start
Hello Im a bit new to Unity and scriptingand and have a problem. I have this weard problem where my Asset saved enemys (Obj with Target chaising Script) keep chaising the point where my target was. If i drag the Hierarchy target in the target (transform) thingy it behaves normal (chaising the target). Can someone Tell me what to do? This is the script:
[SerializeField] Transform target; [SerializeField] float MovementSpeed = 10f; [SerializeField] float RotationalDamp = 0.5f;
void Update()
{
Move();
Turn();
}
void Turn()
{
Vector3 pos = target.position - transform.position;
Quaternion rotation = Quaternion.LookRotation(pos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, RotationalDamp * Time.deltaTime);
}
void Move()
{
transform.position += transform.forward * MovementSpeed * Time.deltaTime;
}
Comment
Your answer
Follow this Question
Related Questions
FindClosestEnemy() change target? 1 Answer
target and look at random enemies 1 Answer
make a ball hit a target 0 Answers
Object Look At Mouse 2 Answers
How to hit two objects with only one shot (raycast) 0 Answers