Adding force to appropriate direction.

This forum is currently in read-only mode.
  • I have a bullet that shoots from the player and the angle of that bullet is judged by which way it shoots (Mouse controlled). This is a platform shooter and when i shoot the box i'm trying to figure out how to make it apply force to the appropriate direction (If bullet comes from left of the box it pushes the box to the right etc.)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't get what you mean, but if you are using physics (which I assume, as you speak of adding force), you would want to use "Set force toward position" and use MouseX & MouseY coordinates.

    Edit:

    Okay, let me see if I got it right...

    1. Shoot a bullet

    2. Bullet collides with box and applies force to it

    3. Box reacts to the force

    In that case, you want an on collision event with "set force" action on box:

    X component = ForceAmount*cos(AngleBetweenBulletandBox)

    Y component = ForceAmount*sin(AngleBetweenBulletandBox)

    ForceAmount could be the bullet's X or Y component of the speed.

  • Thanks! It works but when i shoot at the top of the box it doesnt like "flip" over.

  • Thanks! It works but when i shoot at the top of the box it doesnt like "flip" over.

    You'd have to apply an angular velocity for that. That would require some fancy math I can't seem to figure up at the moment.

  • > Thanks! It works but when i shoot at the top of the box it doesnt like "flip" over.

    >

    You'd have to apply an angular velocity for that. That would require some fancy math I can't seem to figure up at the moment.

    aww. Thanks for the help though.

  • bump

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