- Home /
How do I make a physics based elevator?
I am currently working on a 2d platformer, and there are some objects the player will be able to push and/or carry. I want to create an elevator with two platforms, where the player can place blocks or himself and use the weight difference to move himself (or other objects) up or down. I can easily make the platforms move, but how do I properly weigh the blocks? And, also, how do i handle the object shaking when the platforms move?
Things I already tried:
1. Platform's rigidbody set to dynamic, bound to an anchor gameobject through joint, checking joint "tension". 2. Registering object's mass when entering collision with the platform (does not work for stacks of boxes). 3. Getting the impulse generated by each vertex of the collision, extracting Y component, adding them and using it as a parameter to decide which platform goes up and which goes down (current, problems with impulse variation when platforms move, i.e. when platform goes up, impulse from collision increases, since the platform is moving towards the object as well).
I'm currently moving the platforms using Rigidbody2D.MoveObject() method, and scripts in C#. So, any ideas?
Answer by LexGear · Jul 02, 2020 at 12:35 AM
I've not done much in 2D, but giving the elevator a heap of drag and then using velocity to move it would probably work best.
Thanks for the reply. Just tried it ($$anonymous$$aximum drag + setting velocity). Didn't work.
Answer by sjhalayka · Jul 02, 2020 at 01:04 AM
The equivalence principle states that gravitation and acceleration are identical. So, what you need is negative, repulsive gravitation, to move away from the centre of the Earth. I hope that helps.
Thanks for the reply. The way I tried using forces didn't work. I tried changing the elevator platforms to dynamic gameobjects, then adding forces equals to negative impulse generated by the objects on it, plus an extra to make the platforms move.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Mario Styled Jumping 1 Answer
Jumping from special jump orb 1 Answer
HOLD JUMP BUTTON TO JUMP HIGHER 2 Answers