This a Bug or am I Crazy?

Get help using Construct 2

Post » Tue Sep 08, 2015 3:14 am

Hey there,
I am controlling enemy movement with Line-of-sight, which works just fine. My issue is, if the Player moves away, I want to be able to delay the Enemy reaction time or even prevent movement until attack animation is finished playing. To add a bit of realism.

Anyway, I thought I had it all figured out by using a Wait X Seconds event, every time the Player moved away. Unfortunately, this some how disabled my collision checks and now the monster is just walking right on top of the Player. I have attached an image of exactly how I am playing around with. Does anyone see what I am doing wrong here?

Image
Last edited by Tekniko on Tue Sep 08, 2015 3:29 am, edited 1 time in total.
B
56
S
15
G
13
Posts: 826
Reputation: 17,665

Post » Tue Sep 08, 2015 3:22 am

The enemy still has line of sight during the wait, so it fires again and again and again, etc.

Maybe add a check for "Attack Animation not playing," that way that event doesn't even fire if that animation is in progress?
B
233
S
62
G
33
Posts: 902
Reputation: 40,398

Post » Tue Sep 08, 2015 3:32 am

The enemy will have line of sight, yes, but it will not have been told to set its angle or to move forward for at least one second. It also doesn't explain why collision checks are now ignored.
B
56
S
15
G
13
Posts: 826
Reputation: 17,665

Post » Tue Sep 08, 2015 4:19 am

Try fixing the first issue, then see if it still happens. As Paradox says, you are queuing up at least 60 wait/moves in that one second.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Tue Sep 08, 2015 4:39 am

Condition: Enemy Has lineofsight to player | Action: System: Wait 1.0 seconds
Action: Enemy: Sent Angle Toward (player.x,player.y)
Action: Enemy: Move forward 1 pixels

Sub-Event

Condition: Enemy: is overlapping player at offset (15,0) | Action: Enemy: Set line of sight range to 0

Else
Condition: Enemy: is overlapping player at offset (-15,0) | Action: Enemy: Set line of sight range to 0

Else
Condition: Enemy: is overlapping player at offset (0,15) | Action: Enemy: Set line of sight range to 0

Else
Condition: Enemy: is overlapping player at offset (0,-15) | Action: Enemy: Set line of sight range to 0

Else
Condition: Enemy: is not overlapping player | Action: Enemy: Set line of sight range to 10000
B
10
S
2
G
1
Posts: 92
Reputation: 926

Post » Tue Sep 08, 2015 7:29 am

Solution of tomsstudio seems clever. It propably works.

Personally, I think the way "wait" action works makes it quite problematic to use if you don't exactly know how it works. I prefer making my own timers using instance variables like this:

- Make instance variable ReactionTime for Enemy.
- Condition: Every 0.1 seconds | Action: Enemy: Add 0.1 to ReactionTime.
- Replace all "set line of sight range to 0" actions with Action: Enemy: Set ReactionTime to 0.
- Add another condition to your first event: Enemy: ReactionTime > 1.0.
- Remove your last event (it is now useless).
- Remove wait action.

I feel that in many cases variable based timers give better control over events than wait action or timer behavior.
Lokkim Games: Constructor Dude - Fun platformer game, PuzCro - Difficult puzzle game demo
B
9
S
3
G
1
Posts: 38
Reputation: 795

Post » Tue Sep 08, 2015 1:42 pm

I should have made my answer clearer. The wait is the problem, that event will fire every tick for that first second it's waiting.

So when the first of those seconds is up all those waits that build up will fire each following tick (the end of each of those wait periods) moving your enemy 60 or so pixels. (nothing you can do about the movement, as it all happened 60 ticks ago.)

You could also put an instance variable on the enemy, "TargetSpotted" that you set when the wait event is first fired, so that it doesn't repeat.

Add a condition to event 1: TargetSpotted=0
and an action to event 1 before the wait: Set TargetSpotted to 1
and an action to event 1 after the wait: Set TargetSpotted to 0
B
233
S
62
G
33
Posts: 902
Reputation: 40,398

Post » Tue Sep 08, 2015 3:59 pm

What a weird way to program the Wait function. That explains everything and now I can fix my issue. That's actually a fix for some of my other games as well lol
B
56
S
15
G
13
Posts: 826
Reputation: 17,665


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, valefor and 21 guests