- Home /
Move object with mouse without passing through colliders
Hi,
I have been working on something for along time now and cant seem to understand what goes wrong. Basically i place an object on a plane and if i want to place a second object i can just place it inside the other object. Both objects have colliders and rigidbody's and ar frozen in position and rotation.
I use transform.position to make the object follow the mouse (raycast hit position), i believe this is the problem why it ignores the colliders. I have tried alot of weird solution since the problem isnt there when i unfreeze positions ( it will push the other away, not good).
My question comes down to this i need a way to make the object follow my mouse (raycast) but still use collisions to not pass through each other. I cant seem to get rigidbody addforce to work because it just shoots in a weird direction....
any help would be appreciated.
Take a look at the standard DragRigidbody.js script. You can get it by:
Assets > Import Package > Scripts
It works by using a spring Joint. $$anonymous$$oving by 'Transform.position' often avoids physics.
Your answer
Follow this Question
Related Questions
Is it possible to cast a ray but ignore Z position? 1 Answer
How do I change Raycast's direction based on movement input? 1 Answer
Why is CapsuleCast/Raycast performance effected by rigidbody? 1 Answer
Raycast doesnt detect object in front of rigidbody (player is stuck on wall) 1 Answer
Raycast doesn't register Rigidbody 1 Answer