How do I - choose distance between to objects?

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello Community,

    I have a player sprite and a target sprite. The Target sprite is set to mouse.x/y.

    The player's angle is set towards Target. If I click mouse, it spawns a bullet from Player and shoots towards the Target. WHAT'S HAPPENING IS... If the Target is too close to the player and shoots, then the bullet goes in another direction. I want to stop this from happening.

    How to do this?

    Thanks,

    Roberto

  • I have a player sprite and a target sprite. The Target sprite is set to mouse.x/y.

    The player's angle is set towards Target. If I click mouse, it spawns a bullet from Player and shoots towards the Target. WHAT'S HAPPENING IS... If the Target is too close to the player and shoots, then the bullet goes in another direction. I want to stop this from happening.

    On mouse pressed

    A:> create bullet at player.x y

    A:> bullet set angle of motion to angle(self.x,self,y,target.x,target.y)

    make sure the bullet that is created doesn't have the setting "setangle" ticked.

    if you have this already done in your project, i can't see a reason why it would fly a wrong direction, unless there is some event condition/action that is interfering with it.

    try testing the above on a clean project and compare it with your projects code.

    hope it helps.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks GeorgeZaharia

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