- Home /
Question by
Chan137 · Jan 21, 2021 at 02:53 AM ·
scripting problemrobot
Weird movements of robots???
Simple,I got a robot from assets store which has no scripts attached to it.So i wanted to make it as an Enemy.First I wrote a script to follow player.It works simply it follow my player from long distance.But it cant rotate.This is my script.. public float speed; private Transform target; // this for initialization void Start() { target = GameObject.FindGameObjectWithTag("Player").GetComponent(); }
// Update is called once per frame
void Update()
{
transform.LookAt(target);
Vector3 relativePos = target.position - transform.position;
transform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
transform.position = Vector3.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
transform.LookAt(target.position); //With this line the obj rotate
}
I added didnt add rigidbody for robots.Im very new,so please help!
ill.png
(115.1 kB)
Comment
Your answer
Follow this Question
Related Questions
Change rotation axis for 3D object (robot Joints) 1 Answer
mesh generation + normal maps 1 Answer
Controller Movement Problem 1 Answer