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

Get help using Construct 2

Post » Wed Nov 18, 2015 6:12 pm

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
B
15
S
3
G
1
Posts: 80
Reputation: 1,444

Post » Thu Nov 19, 2015 7:41 am

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.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,273

Post » Thu Nov 19, 2015 12:14 pm

@TheDom How would i go about posting my events? i don't know how to post a screenshot.
B
15
S
3
G
1
Posts: 80
Reputation: 1,444

Post » Thu Nov 19, 2015 2:01 pm

@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
B
15
S
3
G
1
Posts: 80
Reputation: 1,444

Post » Sun Nov 22, 2015 2:22 am

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

Thanks,
Ian
B
15
S
3
G
1
Posts: 80
Reputation: 1,444

Post » Sun Nov 22, 2015 4:10 am

IanHarlow wrote: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.
B
18
S
2
Posts: 48
Reputation: 896

Post » Sun Nov 22, 2015 10:38 am

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Sun Nov 22, 2015 4:19 pm

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

Ian
B
15
S
3
G
1
Posts: 80
Reputation: 1,444

Post » Sun Nov 22, 2015 10:15 pm

@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
B
15
S
3
G
1
Posts: 80
Reputation: 1,444

Post » Mon Nov 23, 2015 9:50 am

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Next

Return to How do I....?

Who is online

Users browsing this forum: 20170217, alimuqaddas, Lancifer, MadSpy, vegapomme27, Zion and 3 guests