System ignoring behaviour for >3 NPC instances [solved]

Get help using Construct 2

Post » Sat Feb 13, 2016 2:12 pm

@blackhornet I think see your point. I'm still trying to get my head around how to think about it in the terms you described. In my head this event went: if x, y, and z, every 0.05 seconds do abc - the timer obviously being just an attempt to save CPU.

If I were trying to save processing overhead then, what would be the correct way to limit this? Sorry to extend this thread but I think it's important to know as my thinking about these things is obviously a bit skewed. Thanks for your answers thus far.

Jimzip :D
B
6
S
1
Posts: 28
Reputation: 465

Post » Sat Feb 13, 2016 4:18 pm

The key is cause-and-effect. Your patrolling loop at the moment says: "I have no idea when the Enemy should move, so I will check every X seconds to force him to move". This statement is false, you know exactly when the Enemy needs to move. He needs to move at the beginning of the game, and he needs to move after a small delay when we hits his PositionMarker - there is no guess work here, these are all absolute points in time that you know about.

I've reworked your code to remove the loop completely. I've added one function, since you need to call the function on startup, and on collision. There were also subtle bugs in there that weren't obvious because you were calling the same code every 0.05 seconds, which was accidentally fixing the problem - namely, you were setting the bullet angle after setting the speed - this actually doesn't work, the speed needs to be set first, or the angle isn't picked up.

http://www.blackhornettechnologies.com/ ... gered.capx
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Sun Feb 21, 2016 2:28 pm

Hey @blackhornet. Thanks a lot for the help, I see the issue now - once I checked your solution it made sense. Much appreciated! I'm now picking through the rest of the code to see where else I've misused loops.

Jimzip :D
B
6
S
1
Posts: 28
Reputation: 465

Previous

Return to How do I....?

Who is online

Users browsing this forum: stevenode, tarek2 and 12 guests