- Home /
character push and drag box
Hi all!
I'm playing with the 2d platform environment and I'm trying to modify the "platformer push body" with the "drag" option. I want to push and drag the object only when a button is pressed and when the button is released the object is not more dragged (or pushed). When the object is not pushed or dragged it turns into a "non movable" object. I found some tips there about "parenting" the character and the object while dragging and release it when the drag (release the button in my case) stops.
Here is my code:
if(Input.GetButton("Fire1"))
{
body.transform.parent = gameObject.transform;
}
else
{
body.transform.parent = null;
}
At the appearence it works but the object physics often go crazy :(
Maybe I need to manage with the transforms of both character and object.
Tnx!
Your answer
Follow this Question
Related Questions
Magical Rigidbody/CharacterController free character...controller - Unity 0 Answers
How can I make my character run over a cube? 0 Answers
How do I make my character jump over a cube with rigid body moving towards it 1 Answer
How to detect whether the object's position is change? 0 Answers
Character still falls. 0 Answers