- Home /
Object collider not operating properly
Using this function I have been able to make an object float to a destined position, how ever, should this object come to a wall or any object that has a greater mass than it, there is no proper collison and it knocks the other object away or goes right through it.
how can i tell this object not to go through others or push over others during this procedure. all object have colliders that work.
function Lerpme(start : Vector3, end : Vector3, speed : float, t : float, start1 : RaycastHit){
start1.transform.position = Vector3.Lerp(start, end, Mathf.SmoothStep(0.0, 1.0, t)); //function for lerpmove
yield;
}
Thanks a ton!!
Answer by Eric5h5 · Feb 18, 2010 at 04:21 PM
If you explicitly set the position of an object like that, collisions can't work. You have to make it a rigidbody and then apply forces, such as with AddForce and so on, so the physics engine can work properly.
(except my daily vote limit is over :o) - @Yisreal And be warned it will be no easy work.
Answer by cregox · Feb 19, 2010 at 08:53 PM
That problem happens because explicitly setting the position overrides the Physics on the object. Like Eric said, you want to add a rigidbody and apply forces or you can even try toying with its velocity a bit.
From my comment @Eric5h5 I meant it will be no easy work if this object actually need to do anything else than "float to a destination point" like stop on it, or bring something along.
If it's just reaching it, then just use AddForce rather than the Lerp. It will throw the object and physics will do the rest. Try it, you will see. ;)