Possible to combine sine and platform behavior?

  • 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?

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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:

    Subscribe to Construct videos now

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)