Behavior/Action Hierarchy

Discussion and feedback on Construct 2

Post » Mon Apr 27, 2015 12:55 am

Hi all,

Can anyone explain the hierarchy of behaviors? When there are multiple behaviors on an object, does the order matter? I believe so. I've been trying to find doc on it. Also in some capxs that people have posted to the forums I've noticed people will use the Bullet behavior and then use Move at Angle action. So I assume normal actions supersede behaviors?

For example I have bullet, rotate and pin on an object1. In my game I have the player on collision with object1 then object1 will be pinned to the player. It looks fine on my desktop, the object1 sticks to the player and but still rotates in place. However, when I run it on my laptop (a less powerful machine) I can see object1 sort of shaking, like it's the bullet behavior that is trying to make it go, but then is pin keeping it in place? and it just so happens on the less powerful machine I'm seeing a slowed down redraw rate which is exposing conflicting movements?

anyone know more about this? thanks..
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865

Post » Mon Apr 27, 2015 1:43 am

This post has the update order using SDK terminology:
viewtopic.php?f=154&t=123265&p=876933&hilit=tick2#p876933

The order you have the behaviors is the order they run. The main exception is the pin behavior which isn't run till after the events. The following is the order things are run:

run Behaviors
run Events
run Certain behaviors like pin are run here instead
Draw


Well it's actually a bit more complex than that when considering multiple object types and instances. You generally don't have any control which object type is run first. The order they're added define the order. Usually it doesn't matter though.

For each object type
For each instance
For each behavior except pin
--- run behavior

run events

For each object type
For each instance
For each pin behavior
--- run behavior

draw


In the example you stated the pin behavior should correct object1's position before drawing, so you the bullet behavior shouldn't affect it.
B
94
S
33
G
113
Posts: 5,353
Reputation: 73,267

Post » Mon Apr 27, 2015 12:49 pm

thanks @R0J0hound, actually I think it was one of your example capxs that inspired my question. I believe it was "GetBack.capx". You have bullet behavior on the 'badSprites' and then you do a For Each and depending on their distance to each other you do a "Move At Angle" on each of them which seems to override the bullet behavior?

Re: my pin example, would the conflicting movement show on slower computers? or could there be a lag? On my laptop (i5 chip, 4GBram), the game is running at a lower fps and it looks like the bullet behavior starts to happen, but is then corrected by the pin. I can't be sure, but the sprite is definitely shaking (it's not super noticeable, but it made me wonder what was happening) and it does NOT do that on my desktop computer.
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865

Post » Mon Apr 27, 2015 2:47 pm

The events run after the behaviors so actions do override it. For the pin behavior even on a slow computer it should not jitter, because drawing still isn't done till the behaviors and events are done running.
B
94
S
33
G
113
Posts: 5,353
Reputation: 73,267


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests