Creating a repel volume
I have some objects that I'm spawning into a scene, but I want to kick them out of their spawn area with a trigger collider. Basically they spawn in a trigger volume, and I want to accelerate them out of that volume along it's Z axis (the axis that faces out the door), but I'm having trouble figuring out how to do that. I thought adding this to the push volume would work:
var pushVector = transform.TransformDirection(0, 0, pushForce);
rigid.AddForce(new Vector3(pushVector.x, pushVector.y, pushVector.z), ForceMode.Impulse);
But the above only works in certain orientations. How can I translate the force so that it always moves along the Z axis of the collider (which is embedded in another object)?
Your answer
Follow this Question
Related Questions
Moving a child object to collide with wall. 1 Answer
Destroy instatiate object on trigger enter / collision,destroy instantiate prefab on trigger enter 0 Answers
Can’t keep the position 0 Answers
How to get the Collider other element Rigidbody? 0 Answers
Remove Door's collider if cube is in the trigger,Destroy Door's Collider if box is in the trigger 0 Answers