Making an actor graphic scale up and down based on the objects speed
Toby
Member Posts: 478
Trying to make an actor graphic scale up and down based on the objects speed of movement.
I need to achieve the following:
1. Have a game attribute game.speed defined in game attributes.
2. If the player actor is moving at a low rate of speed the actor it influences does not change eg 300px wide.
3. At a highter rate of speed the influenced actor width is divided by the speed of acceleration to reduce the width. change attribute - self.sizewidth - game.speed/300
4. Slowing the speed of the actor expands the influenced actor to it's original dimensions gradually. (sort of working by changing the expression above)
I have the speed up / scale down bit working just fine, it's the setting Minimum/Maximum width and scale back up relative to speed I'm having trouble with.
Any advice appreciated.
I need to achieve the following:
1. Have a game attribute game.speed defined in game attributes.
2. If the player actor is moving at a low rate of speed the actor it influences does not change eg 300px wide.
3. At a highter rate of speed the influenced actor width is divided by the speed of acceleration to reduce the width. change attribute - self.sizewidth - game.speed/300
4. Slowing the speed of the actor expands the influenced actor to it's original dimensions gradually. (sort of working by changing the expression above)
I have the speed up / scale down bit working just fine, it's the setting Minimum/Maximum width and scale back up relative to speed I'm having trouble with.
Any advice appreciated.
Comments
Constrain Attribute: self.Width = min(300,game.speed/300)
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Have the code working, but it's going the opposite to what I would like. How do I make it change from big to small rather than small to big? My speed attribute starts at zero and counts up so my actor only gets bigger as the speed increases. Can I reverse this somehow?
I've adjusted it to constrain the max and minimum width so it does not vanish or get too big like so. (Scales between 300 & 100 pixels only.)
Constrain Attribute: self.Width = min(300,game.speed/15)
Constrain Attribute: self.Width = max(100,game.speed/15)
4500 = 300*15.
min(...) -> Your upper limit is 300, so when game.speed is 0, it becomes min(300,300)=300. When game.speed is greater than 0, it gives you the value of (4500-game.speed)/15 to be subject to the max function as it is any number less than 300. When game.speed is less than 0, (4500-game.speed)/15 becomes greater than 300 and is defaulted to 300 by the min function.