Possible to combine sine and platform behavior?

Get help using Construct 2

Post » Sun Jan 08, 2017 2:02 pm

I have an object that has both platform and sine behavior. I've disabled default controls for the platform behavior (as it's a non-player object) and set it's gravity to 0 and I'm having it move horizontally by using simulate platform pressing left/right events. This works as intended, however I would like the object to do a slight vertical up&down movement by sine behavior at the same time (while it's moving horizontally). It seems that the platform behavior is interrupting the sine movement from moving up and down and only the horizontal movement happens.

Am I doing something wrong or is it simply just not possible to combine these two movement behaviors?
B
32
S
9
G
4
Posts: 133
Reputation: 4,350

Post » Sun Jan 08, 2017 4:58 pm

If the non-player object is simply performing a ping-pong movement left and right it might be better to remove the platform behaviour and either:

1) add another sine behaviour set to horizontal movement

or

2) give the object max_X, min_X and speed instance variables then add code along the lines of:

Every tick object.X = self.X+self.speed
If object.X > object.max_X OR object.X < object.min_X, trigger once, object.speed = object.speed*-1
B
19
S
8
G
3
Posts: 429
Reputation: 3,972

Post » Sun Jan 08, 2017 9:45 pm

Use an invisible 'controller' sprite object with the platform behaviour. Then set/pin a graphical sprite object to the controller sprite position and run any other graphical/positional adjustments such as your sine behaviour to this sprite without it affected the platform behaviour.
Image
B
30
S
9
G
3
Posts: 171
Reputation: 3,329

Post » Mon Jan 09, 2017 7:09 am

Yes. It's possible.
Divide your sprite into different Sub-Components, put them into a family and apply the Sin behavior to the family.
You would then have to decide which part of the family would have the Platform behavior, just set all NON-PLATFORM family members to the position of the platformed member at all times.

This is what it'd would look like ideally: https://www.youtube.com/watch?v=hN186HL6lhM
Check out the exploration and battle parts of DARKEST DUNGEON.. You'll see the characters' body parts all use a sine behavior to achieve the breathing effect when the characters are idle.
Image Image Image
B
29
S
11
G
27
Posts: 730
Reputation: 17,002


Return to How do I....?

Who is online

Users browsing this forum: zenox98 and 13 guests