Hey guys! I'll explain the script below, what u need to concentrate there that it casts a ray when there's a left mouse click and the tag is terrain, so it goes to the hit.point, if the tag is "monster" it goes the monster's.position, but the problem is that when I click on the monster's tag its speed increases like mulplies 5 times faster.
I have no idea why it happends, can anyone tell me why?
Also, I tried adding * Time.deltaTime(near the speed) in the `Move` function, and it goes okay to the monster's position, but when I hit the terrain's tag it goes to that hit.point faster.
http://09duck.pastebin.com/CQvhE9iC
Mike_3
2
As i replied in your other post(s) - you're calling the coroutines once a frame. On top of that, each coroutine is looping, to move the object
What you need to do is something like this:
function RotateTowardsMob() {
if(target != null && Vector3.Distance(target.position, transform.position) >= 0.01){
var direction : Vector3 = transform.position - target.position;
transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation(-direction), 0.2* Time.deltaTime);
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
}
}
for all of the ones that you're calling each frame