0 Favourites

Move + Aim Phys Object Accurately

  • If I wanted to drag a phys pistol anywhere on the screen, making it accelerate towards and aim towards the mouse pointer, stopping acceleration when it reaches the pointer so you have an accurate shot, how would I go about stopping it's movement?

    The problem I'm having with this is that I can drag, drop and move the gun just fine, but once it gets to the mouse it starts doing loopies around the mouse position, or if I make it so it can't do that, it just starts falling downwards because of the phys gravity, still aiming towards the mouse pointer. There doesn't seem to be a way to disable or enable physics/set the gravity of a single object, otherwise this would be a lot easier for me.

    Anyone have any suggestions?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • If it's a physics object it'll have a couple of built-in variables that are useful , VelocityX and VelocityY. If you can get these to decelerate properly, you can have a trigger that is checking if the pistol has been fired but the VelocityX is below a threshold, then use the action "Physics: Object settings Set immovable". If the velocity checking is not a route you'd like to go you can have it check a threshold distance from your mouse pointer (Mouse.X/Mouse.AbsoluteX) and use that to trigger the physics object immovable. Good luck!

    Paul

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