Forums

OverviewV-Play 1 Support › How to get collision impulse

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5561

    Elisabeth

    Hi all,

     

    I want to decrease player’s health in case of a collision. In the docs (BoxCollider) it is suggested that one could use fixture.onBeginContact to start a timer which decreases health periodically as long as the collsion happens. This approach doesn’t seem to take the force of the collision into account. So I think, touching something softly but for a long period of time is more unhealthy than colliding with high speed and bumping off. Box2D offers the normal impulse (“The normal impulse is just the normal force multiplied by the time step.” [Box2D manual]). Is it possible to access this property in V-Play? Is there another solution?

     

    Thanks for any advice, cheers

    Thomas

    #5565

    David

    Hi Thomas,

    you can see Ball.qml of the VPong demo which uses circleCollider.body.linearVelocity to determine the velocity of the ball which is decreased when it hits another object. There is also a counter available which increases the final force of the ball when the limit is reached. A combination of those properties could also be a solution for your Problem. Furthermore, you can start the timer with fixture.onBeginContact and stop it in fixture.onEndContact so you can also use the information for the duration of the collision.

    Cheers,

    David

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support