Interacting with NPC while facing him

For questions about using Classic.

Post » Mon Aug 05, 2013 3:45 am

I've been trying to figure out what I could possibly be doing wrong here for a very long time so I'm just gonna go ahead and ask...

My problem is interacting with NPCs - everything works fine except for the events that are supposed to determine if the player's sprite is facing the NPC. Here is essentially what I have...

After picking the right NPC object that's closest to the player, I have a long list of events that are supposed to detect the player's position compared to the NPC's. In other words...



So, if the player's ("AlienBox") X position AND Y position is higher than the NPC's, the player should be somewhere along the bottom right corner of the NPC. Then, if the angle of the player is appropriate, a value for "Facing" is set to 1.

The issue I'm having isn't that this doesn't work - it's that when I add events for each possible position (three more, for the other three corners), only the first two that I've listed do anything. So, if I have the events for bottom right and bottom left up higher on the event sheet than top right and top left, only bottom right and bottom left will function. I've mixed and matched all 4 events, and regardless of what they say, only the first two I've listed work.

I'm really stumped by this one... no clue what could possibly be going wrong. The only other way I can think to test positioning would be to add a detector object, but I would really prefer not to do that. Anyone have any idea what might be going on here?Jalopes2013-08-05 03:47:05
B
10
S
2
Posts: 22
Reputation: 644

Post » Mon Aug 05, 2013 5:07 am

NEVERMIND. That was stupid - the Else's are conflicting, duh.

But I guess I'm still not entirely sure what to do here for this. I can't figure out a way to set "Facing" back to 0.

I'm sorry this problem is going to end up being really specific... I'll try to go into any more detail if need be, but hopefully I'll figure something out.

EDIT: yaaaay I figured it out! Or, at least, I got something working. So... I guess nevermind completely then! I'll post if I run into some other snag.Jalopes2013-08-05 05:33:43
B
10
S
2
Posts: 22
Reputation: 644

Post » Tue Aug 06, 2013 6:57 pm

Another way to do it is to have an invisible sprite that is always in front of your player. If invisible sprite overlaps NPC and action key is hit, trigger event.
B
4
Posts: 14
Reputation: 280

Post » Tue Aug 06, 2013 7:03 pm

That's something I considered, but I've been trying to avoid using trigger objects like that, mostly because I think it'll be good practice for me to come up with other ways, haha.

That might actually be more efficient than the way I'm doing it now, though. Oh well.
B
10
S
2
Posts: 22
Reputation: 644

Post » Tue Aug 06, 2013 11:27 pm

You might not need to keep track of an invisible sprite.

Try the overlapping by offset condition for your player.
For x and y use cos(Player.Angle)*distance and sin(Player.Angle)*distance.
For distance you just do however wide your character is i guess.

I'm thinking of doing the same thing in my game, and I was going to try it out today.

Good luck, I'll report back if it works in my game.
B
12
S
2
Posts: 32
Reputation: 856

Post » Wed Aug 07, 2013 5:25 am

Or even use the line of sight behaviour as a range test.
B
4
Posts: 14
Reputation: 280

Post » Wed Aug 07, 2013 7:03 pm

[QUOTE=Fervir] You might not need to keep track of an invisible sprite.

Try the overlapping by offset condition for your player.
For x and y use cos(Player.Angle)*distance and sin(Player.Angle)*distance.
For distance you just do however wide your character is i guess.

I'm thinking of doing the same thing in my game, and I was going to try it out today.

Good luck, I'll report back if it works in my game.[/QUOTE]

Seems like an interesting solution. What I ended up doing was putting a "trigger once" on all of the else's - so they conflict with each other on one tick, but that's not really enough to make any significant difference.

The line of sight behavior sounds interesting, too, I've never tried it. If my system for this starts giving me trouble, I'll definitely look into it.
B
10
S
2
Posts: 22
Reputation: 644


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests