- Home /
Create 2d shape whose position follows 3d game object, and affect 3D model position on collision
Hello,
I'm seeking some clarity on this concept. No code yet, just want some ideas on how I'd implement this in Unity.
I'm working on a 2.5D platforming (ish) game. The character model is 3D but moves on a 2D plane. For several reasons I won't explain here, I would like to use a diamond-shaped object to detect environmental collisions for this model. Please don't tell me to use Unity's rigidbody, because rigidbody physics will not work for my game. This diamond would dynamically scale in size based on the current size of the model (ie is it crouching? extends body while jumping? extending its arm out), and when the diamond collides with an environment object, like a wall, I want my model to not be able to pass through the object.
First, how do I make this 2d object follow my 3d model all the time? My idea was to constantly poll for center coordinate in the 3d bone mesh and translate the diamond's position on each frame based on where that point is. As for size, I'd look at the four bones that are at the edges of the character, and make the diamond as a percentage of this mesh. When the diamond collides with something (using onTriggerEnter
, presumably), prevent the diamond from clipping through. Set the 3d model such that it cannot move past a certain radius around the diamond.
Is this the right way to go about it? Is it possible to code? Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220613200239im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Stacking mechanic (Parenting Prefab to another prefab on collision) 2 Answers
Collision vs trigger 1 Answer
Change NavMesh Speed after collision/trigger just for 1 object 1 Answer
Trigger if 3 Objects Collide at the same time 0 Answers
How to perform a smooth push in the opposite direction of a wall 0 Answers