- Home /
Looking for a contact.point alternative with triggers
Hey all,
Working on a game now that works with dragging rigid bodies across the screen. At the moment there are areas where you can't drag the object through them, but you can throw them through. At the moment this works with triggers.
For example, you're holding an object and you try and drag it through one of these areas, but when it hits the trigger area, the object is automatically dropped. So you pick it up again and then 'throw it' through: the object passes through the trigger because you're not currently dragging it and the physics just does all the work.
So, all that is working great.
But now I want to instantiate something at the exact point it hits the trigger, which I can't figure out how to do. I can find the exact contact point with OnCollisionEnter and ContactPoint.point, but then nothing else can pass through it because it's not a trigger anymore. Likewise, I've tried adding the above to the object itself, but it doesn't register the collision as it's hitting a trigger.
Any ideas?
When do you want to detect the contact point? Want the object is dragged or when it is thrown?
$$anonymous$$aybe set onTrigger to false when OnTriggerEnter() is called then Use OnCollisionEnter() or OnCollisionStay() to recover the contact point and reset onTrigger to true?
If you want to instantiate something at the point an object hits the trigger, why not just use its position from OnTriggerEnter() if its just entered the trigger it's current position is its point of contact with that trigger.
If the object is small this will work well enough
Apologies, I was expecting an email alert when someone commented on this, so missed all your comments.
The way I solved it at the end was to add new triggers to each edge of the object being dragged in separate empty game objects. These then fired when i hit the forcefield. Not that elegant, but works fine. Also was handy as I could use the same triggers for sounds for when it was dragged into other things.
While it's a 3D game, everything is dragged and moving along one vertical plane, so that's why this worked well with just a trigger at each end. For something more complex I imagine I'd need a more complex solution.
Your answer
Follow this Question
Related Questions
Character controller collider? 0 Answers
Response speed in OnCollisionEnter / OnTriggerEnter 1 Answer
How to detect collision without OnCollisionEnter or OnTriggerEnter? 1 Answer
OnTriggerEnter2D only one time 1 Answer
How do I use an enemy's OnTriggerEnter to collide with stationary player? 2 Answers