- Home /
How to Check Collision When Pushing / Pulling Object in 3D Space
I am currently trying to develop a FPS push/pull (in 3D space) mechanic with the following requirements:
Player must "grab" object
Player must face object's center to grab it
Object should turn with player (stay in front of player while turning - partial orbit)
Object can be pushed or pulled
Object should move with player
Object must account for collisions
Object moves freely along X/Z (no grid)
Object must be able to fall when pushed off ledges
I've managed to solve for most of these requirements by using a rigidbody with gravity on the object and a kinematic rigidbody on the player. I connect the object to the player with a Configurable Joint to get the desired movement, but collision is still causing me grief.
I'm currently using a "crate" for testing that is 1.5x1.5x1.5, meaning that it's wider than the standard FPS player. When I move the player up against a wall (from the side), the crate starts to "climb" in an attempt to align with the player's Z, especially when the player starts turning towards the wall.
I would like to implement collision in such a way that when the crate can no longer move in a particular direction, neither can the player. Any ideas on how I can do this?
Been working on this for days, and still no luck. I've been trying a different approach than the one I initially asked about.
I'm using the limit property of the configurable joint I'm using to allow the object to catch on corners in such a way that when the player leaves a secondary collider on the crate it breaks the joint and the player "drops" the object, not unlike how catching an object on a corner in Portal works.
Having more luck trying this way, but still not there yet because of how allowing for a limit on the XZ keeps the crate from moving with the player.
Any thoughts still more than welcome.
Ins$$anonymous$$d of a Configurable Joint, would maybe applying Force depending on the distance of the player work? If the player is further away, the force would point towards the player, if the player gets close the force pushes the crate away.
I've thought about trying to use AddForce, but the issues I run into with that are: 1) I don't know how to adjust the force to accurately match player movement speeds 2) Since the object is supposed to act like it's "grabbed" it needs to always be close to the player until it has been released by the player or by collision that pulls the object away from the player
Your answer
Follow this Question
Related Questions
Prevent a specific RB to influence another, but still collide with everything 0 Answers
Play animation when 2d character hits collider. 0 Answers
Child Colliders 0 Answers
Pulling objects 2 Answers
Cube collision problems when held 0 Answers