- Home /
Collision without physical behaviour.
Ive got some quite big object, which uses a box collider. I want to translate and rotate this object including collision detection at a quite high speed. What I do now is, that the object to collide with has a mesh collider attached and the moving object has its box collider and a rigid body as components. I move the object using transform.Translate(), it works kinda okay at low speed, but the object keeps sliding after collision in a kinda strange way. At higher speed it tends to drive crazy on collision. Any ideas on how to get this to work stable? And I also wonder and ask you now: how to get information on the actuall movement my object did when executing the Translate? As I basicly need the actual direction and distance.
My alternative approach is setting the object to kinematic and the environment as trigger. I can than use the OnTrigger events to code the collision behavior myself. The problem here is that I need some information about the collision point like position and normal. I could get some normal by casting a ray, but I need some direction for the ray and just using the movement direction would give me wrong results in most cases.
I hope for some helpfull ideas :) Thanks.
Answer by StephanK · Jul 23, 2010 at 03:17 PM
Using transform.Translate() is not recommended when dealing with rigidbodies, as this circumvents the physic engine. You are able to move to objects so they completly intersect each other. Then in the next physic update the physic engine will apply forces to solve this intersection. This might result in the behaviour you mentioned. (going crazy) The "correct" way to move your object would be either to apply forces, or for a more direct control modify its rigidbody.velocity. rigidbody.velocity is also the way to get the current direction and speed.
If that also doesn't help try changing the update rate of the physics engine using Project Setting -> Time -> fixed Timestep.
Thanks for your answer. I am now trying to set the velocity directly. I basicly have a small wall of about 3/4th the height of my box collider and move my object with the box collider against that wall. I just want it to stop but ins$$anonymous$$d it starts moving up and finally kinda explodes, as it moves up at a very height speed as soon as it got above the wall. The makes than when one thinks about how such a physicsengine works, but how to fix that?
Your answer
Follow this Question
Related Questions
Collission and Trigger on Same object 0 Answers
Trigger if 3 Objects Collide at the same time 0 Answers
overlapsphere to destroy NPCs on exit 1 Answer
OnTriggerEnter Not Working 3 Answers