How do I fix enemy's size while sine behaviour is active/de?

0 favourites
  • 2 posts
From the Asset Store
220 Food Sprites in 16x16 pixel size. Perfect for items for a retro style game.
  • Hey everybody,

    I’m having a small problem with sine behaviour and setting size of sprite object. I have 2 enemies, small and big. Both are different in size and GFX.

    What I want to do: when player character is standing on top of the enemy, enemy will squash a bit. Then, when player isn’t standing on top of the enemy anymore, enemy will will go back to it’s original size.

    I’m using 2 sine behaviours, one for heigh, one for width. Sine which controls Width is in control. That means I’m using it’s CyclePosition to apply same value to the height sine’s CyclePosition. So when width sine's CyclePosition is 0.1, height sine's CyclePosition is also 0.1.

    Setting enemy's size back to original is done by storing enemy’s original size to 2 instance variables (originalWidth and originalHeight) on creation. I hard-coded that when sine.CyclePosition is greater than 0.5 -> set size to self.originalHeight and self.originalWidth. I hope this is more easier to understand in-game and by reading events than me explaining it here :)

    Problem is: with the big enemy everything is a mess. Size isn’t correct when landing on top of the enemy. Same thing when setting big enemy’s size back to original. With small enemy everything is working fine and as expected.

    I think, I THINK big enemy’s size is somehow treated the same as small enemy’s size. How? Because at the moment when player lands on top of the big enemy, it’s size is immediately set and sine (width) behavior isn’t activated. I checked it through debugging layout. Also bigger enemy’s height while squashed should be different than small enemy’s height. Now they are same. I set height to be 1/3 of enemy’s height while it's squashed.

    If someone has some free time and want to help me to figure out the problem, I would really appreciate that :)

    Link to example: h*t*t*p*s://

    Remove those * signs from https and you are good to go :)


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Solved!


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