How do I make the collision polygon independant of the scaling up and down of its sprite ?

0 favourites
  • 5 posts
From the Asset Store
Perfect Particles
$2 USD
80% off
Particles support animations, collisions, effects and etc.
  • Hello,

    My project has sprites that all have collision polygons set up to react to the hovering of the mouse ; and the behavior of those sprites is to scale up a little bit when the mouse is over it (and then scale down when the cursor goes away).

    My problem is, the collision polygons scale up too - and that can create some glitchy behavior from the mouse cursor (it looks like it's staggering at ultra speed whenever it is "caught" between different states of the scaling sprite).

    How can I avoid that ? One way would be to create collision polygons on invisible sprites on top of the actual sprites so that they don't scale up at the same time as the actual sprite ; but it's going to be long to set up (I have many sprites of different shapes), so I was wondering if there was an easier method to go about it I didn't think about ?

    Thanks for your input !

  • You could just set the scale to 1 when checking for collision and back to scaled directly after. So the idea would be to save the current scale to a variable, set scale to 1, check for collision, then restore the scale. With some fiddling it should work with whatever system you have in place to adjust the scale.

    Every tick:

    — sprite: set savedscale to self.width/self.originalWidth

    — sprite: set scale to 1

    — sprite: set scaleMe to false

    Mouse: is over Sprite:

    — sprite: set scaleMe to true

    Every tick:

    — sprite: set scale to savedscale

    Sprite: scaleMe

    — sprite: lerp scale to 1.5

    Negated sprite: scaleMe

    — sprite: lerp scale to 1

  • Hye, thank you for your response !

    Unfortunately I have a hard time figuring it out ; it looks like the scale of the sprite is set in two different "every tick" actions ? Also, "sprite: set savedscale to self.width/self.originalWidth" a division or just a slash symbol ?

  • The idea is

    Save scale, make unscaled, check for collision, then restore scale. I guess what makes it complicated is depending on if the mouse is overlapping or not you also what to change the scale. What i wrote was on possible solution.

    And yes that’s a division. There is no expression for an objects so that is a way to calculate it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay, thank you !

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