OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

rapier-2D javascript Physics Engine - Toggle Solidity

  • Thread starter Thread starter Nomanic
  • Start date Start date
N

Nomanic

Guest
I would be grateful for any help at all please!!! I am new to RAPIER, and am stumped.

I am writing a shoot'em up game using the RAPIER2D JS PHYSICS ENGINE.

In it, I would like to have a retractable blast door. It raises up out of the floor to block the player, retracts under the floor if they have a key.

It's top-down and 2D, so it's just a rectangle that is there one minute and gone the next.

Ideally in the game I can toggle the 2 behaviours at will, opening and closing the doors as I wish.

Way I see it, When the door is shut, I would like a static solid object that repels forces applied to it, things bounce off it and it doesn't move. When the door is open, essentially - it doesn't exist.

I understand how to make a rigidbody and collider that is fixed, for the closed door. So all the physics applied to it works as it should. But I can't "switch it off" somehow. I wondered about moving it offscreen and back, but fixed bodies can't be moved.

I considered a dynamic body with HUGE mass, that I just move in and out of place. But docs suggest you don't just TELEPORT objects (which is what I am essentially doing) And surely this is a fixed object not dynamic.

Another answer could be to just remove the body from the world and re-create each time?

But these seem hacks. I wondered if there was a "proper" way of doing this?

There are other instances where I need this, and I want to learn to utilise RAPIER correctly.

I hoped there is something far more elegant.

I do not understand how I can make this object "appear" and "disappear" at will.

Thank you.

<p>I would be grateful for any help at all please!!!
I am new to RAPIER, and am stumped.</p>
<p>I am writing a shoot'em up game using the RAPIER2D JS PHYSICS ENGINE.</p>
<p>In it, I would like to have a retractable blast door.
It raises up out of the floor to block the player, retracts under the floor if they have a key.</p>
<p>It's top-down and 2D, so it's just a rectangle that is there one minute and gone the next.</p>
<p>Ideally in the game I can toggle the 2 behaviours at will, opening and closing the doors as I wish.</p>
<p>Way I see it,
When the door is shut, I would like a static solid object that repels forces applied to it, things bounce off it and it doesn't move.
When the door is open, essentially - it doesn't exist.</p>
<p>I understand how to make a rigidbody and collider that is fixed, for the closed door.
So all the physics applied to it works as it should.
But I can't "switch it off" somehow.
I wondered about moving it offscreen and back, but fixed bodies can't be moved.</p>
<p>I considered a dynamic body with HUGE mass, that I just move in and out of place.
But docs suggest you don't just TELEPORT objects (which is what I am essentially doing)
And surely this is a fixed object not dynamic.</p>
<p>Another answer could be to just remove the body from the world and re-create each time?</p>
<p>But these seem hacks. I wondered if there was a "proper" way of doing this?</p>
<p>There are other instances where I need this, and I want to learn to utilise RAPIER correctly.</p>
<p>I hoped there is something far more elegant.</p>
<p>I do not understand how I can make this object "appear" and "disappear" at will.</p>
<p>Thank you.</p>
 

Latest posts

Y
Replies
0
Views
1
Youssef Ismail
Y
Top