Set Physics velocity to 0 or disable Physics?

0 favourites
  • 7 posts
From the Asset Store
Physics Block Puzzle game template for Construct 3
  • Which is best. To set Physics Velocity X,Y to 0 or to disable Physics... If you want to move an object. For example the player has to spawn in a new position.

    I have an object that after it has landed, I need to respawn it ( move the object ) to another location. At the moment I set Velocity to 0 and Angular velocity also to 0. After that I position my object to the new location. ... I forgot.. I also set the World.Gravity to 0 before I move my object.

    Is it better to just disable Physics while I reposition my object you think?

  • I'm not sure what you mean..

    What is the reason for changing the velocity and or disabling physics?

    Is landed the same as on collision or does it only apply when the object has become stationary?

    Respawn/move, I'm assuming this is done in one tick?

    Would destroy the object and create a new one work?

  • I'll explain more.

    I have a player that throws an object. And I'm using physics.

    When the object hits a wall - it instantly has to stop. Like if you throw a knife into a wooden wall. The same has to happen when the object hits another player.

    To achieve this, I set the objects velocity and angular velocity to 0 when it collides with a wall/ground or another player.

    After this has happened - it's the other players turn to throw. So I reposition the object to the another player.

    I do not want to destroy my object, just reposition it after it has "landed/hit something"

    I'm doing a multiplayer game, so it's a bit complicated to do some things, that normally would be much easier if it just were single player.

  • I'm not sure why repositioning the object would be better than destroying it and spawning it at the right player, but it seems to be only one object we are talking about, so I guess it doesn't make much impact on performance in what way you do it..

    I would personally choose disabling the physics behaviour on the object when not needed and reenabling it when the physics are needed again, but like I said, performance wise the difference would probably not be noticable, so I guess it's a case of whatever you like best..

    You could ofcourse check the difference in performance using the debugger to make sure..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok. I'll consider disabling it to see what happens. It may be easier and to avoid "strange" behaviours.

    Physics are a bit unpredictable and I have issues and "strange" behaviours sometimes. And it only happens after I've moved the object. The performance are no problems though.

    I need things from the object, instance variables, position and such, so I cant destroy it without big problems.

  • Agree with LittleStain. I would disable physics in that moment but just because it's a one line action compared to set velocity, angular velocity, etc.

  • I understand. Thanks

    I was wondering. Is it best practise to disable physics if you have to move an object (Position it) - that has the physics behaviour assigned to it?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)