See if touch.x touch.y in in front of player HelpPlease

0 favourites
  • 11 posts
From the Asset Store
Surena Touch
$2.50 USD
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • HI

    in my 2 player game, the players are facing the other, and trying to shoot at the other player. My problem is, and i have searched the internet, the players can shoot behind themself. I have no idea where to start, and it is starting to bug me.

    So how would i test if touch.x touch.y is between 45 -45 degrees of the player please help.

    Thanks in advance Ian

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need to provide some more info. Some screen shots of code or post a capx.

    You could spawn an invisible sprite at touch.x, touch.y while is intouch then

    Spite.X < Player.X 》 Do Something

    Spite.X > Player.X 》 Do Something

    Also use Set Poston for sprite to touch.x, touch.y every tick while it's in touch.

    And destroy the sprite while it's not in touch.

  • TheDom How would i go about posting my events? i don't know how to post a screenshot.

  • TheDom I think I may have said it wrong.. I need the player to be able to shoot in an area like this

    X =. Player

    / or \ = border

    .= can not shoot here

    ....../

    ..../

    .../

    X

    .../

    ...../

    ......./

    I don't know if that will help, but that is how I need it they should only be able to shoot in front of the borders, not straight up or down. And if they tap behind a border it un-selects their weapon choice

  • Does Anyone Have any suggestions, tips, ot anything? All help is welcome and appreciated!

    Thanks,

    Ian

  • Does Anyone Have any suggestions, tips, ot anything? All help is welcome and appreciated!

    Thanks,

    Ian

    If you upload your .capx, we would have a better idea on what it is you are trying to do.

  • Is this the condition you are looking for?

    system is between angles: angle(player.x,player.y,touch.x,touch.y) is between player.angle-45 and player.angle+45

  • LittleStain Yes Thank you! That appears to be it! Thanks for your time

    Ian

  • LittleStain after a little testing it did not work for the other side? how would i reverse it?

    .= can shoot

    / Or \ = border

    X = player

    /

    ../

    .../

    ..../

    ......X

    ....../

    ...../

    ..../

    Thanks

  • What do you mean by other side?

    Only one side is in front of the player right?

    If you are mirroring the player, The players angle stays the same, only the animation is mirrored, so you would have to create a different event for that..

    From the top of my head, when mirrored to get the same effect, the angle(player.x,player.y,mouse.x,mouse.y) should be between player.angle+135 and player.angle+225

  • Ok thanks

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