- Home /
How do I "remove/disable" collision?
Hi, I have an object moving using rigidbody and addforce. And Iam spawning some other objects that are in the way of the first object. When they collide, there is a script for the collision detection which works fine. Problem is, when they collide, the main object slows/stops and starts spinning and in the end it flies away. I need the collision to happend but I cant have any of these results. The script removes the 2nd object on collision but it still moves the first object. I've tried fixing the rigid body of the first object but then I cant move it with addforce.. what do I do?
Answer by fafase · Mar 17, 2013 at 05:19 PM
You would have to set the "On the way" object to isTrigger but you would still have to modify your scripts.
All OnCollisionEnter(Collision col)
becomes OnTriggerEnter(Collider col)
and you need to set all colliders to isTrigger.
As a result you get the collision but when the first object hits them, you get your collision but no resolution meaning it just get through it.
It would be easier to write movement code for the main object than collision response code for the others, or am I missing something / not getting your point?
You may be right. It depends what the OP is doing with the object on the way, do they disappear, do they get pushed away while the main continues? If first, I am right :), If second, you are right :(
Thanks to both of you. I think fafases solution is better, I will try it out tomorrow, maybe on tuesday. The object indeed disapears after the collision. I dont think Iam capable of writing my own movement script and I already wrote the game for the default unity force system and it took some time to balance it out.
Answer by infinitypbr · Mar 17, 2013 at 05:54 PM
I think there's a checkbox in the collider or rigidbody area on the object that forces it to not rotate. Click those and it won't move on the axis you choose. There's 6 checkboxes, 3 for rotation and 3 for movement. I'm not sure how to make it not slow down though.
Answer by Loius · Mar 17, 2013 at 05:57 PM
You'd have to set the velocity of the object directly, after the collision. You can also disable rotation easily in the rigidbody inspector.