Hi,
I have a bit of a problem with a script I’m currently using.
I want a gameObject to move towards me, which works, but the closer he gets, the slower he becomes, which is something I’m not to keen on…
Here’s the part of the script:
transform.LookAt(player);
transform.eulerAngles.x = 0;
var target : Vector3 = GameObject.FindWithTag("Player").transform.position;
var moveDirection : Vector3 = target - transform.position;
moveDirection.y = 0;
gameObject.rigidbody.velocity = moveDirection * Time.deltaTime * speed;
As you can see, the velocity is calculated from the current position of the player minus the position of the gameObject, so it makes sense that the gameObject becomes slower the closer it gets to the player, but I couldn’t find an alternative to that yet.
If anybody has a solution at hand, that doesn’t even involve a RigidBdody component, I’d be more than happy to try it, because this script is the only reason I’m using a RigidBody anyway…
Thanks…
/edit: Just came across my mind, even though it’s not related to the original question. Can someone explain to me, how I’m using Bounds properly? I’d like to instantiate an object with it’s lowest point at another objects lowest point, so I figured Bounds were the way to go, but the Bounds section in the scripting reference isn’t exactly bursting with code examples… :o