Make actors grow / shrink according to distance from any given point?
Loaded
Member Posts: 240
I need to try and resize an actor from 15 to 40 (width and height) over any given distance from another actor (emitter), I would like to avoid using interpolate and so far have the actor resizing using magnitude...
magnitude(self.Position.X-emitter.Position.X,self.Position.Y-emitter.Position.Y)
This is great (Thanks @RThurman ) but I want the actor to grow from size 15 to size 40 during its journey from the emitter to it's final position. It's worth noting that the final position is a random(x,y).
Anyone got any ideas?
Thanks, Loaded.
magnitude(self.Position.X-emitter.Position.X,self.Position.Y-emitter.Position.Y)
This is great (Thanks @RThurman ) but I want the actor to grow from size 15 to size 40 during its journey from the emitter to it's final position. It's worth noting that the final position is a random(x,y).
Anyone got any ideas?
Thanks, Loaded.
Website » Twitter » Facebook » Loaded Arts - Fun for thumbs.
Developer Blog » 08/01/2015 - Week 72 – Apple, the great dictator…
Comments
Website » Twitter » Facebook » Loaded Arts - Fun for thumbs.
Developer Blog » 08/01/2015 - Week 72 – Apple, the great dictator…
1) you could use the min and max functions
max(15,min(40,magnitude( game.emitterX - self.Position.X , game.emitterY - self.Position.Y )))
2) or you could use a formula that wont go below 15 but will keep the actor growing so that it reaches 40 when it is about a screen length from the emitter
15+magnitude( game.emitterX - self.Position.X , game.emitterY - self.Position.Y )*.05
The ".05" is a multiplier that you can mess with till you get the growth rate you want.
In that case, the first thing you will need to do is get the initial distance between the actor and its final position:
Change Attribute: self.InitialDistance To: magnitude(self.finalX - self.Position.X , self.finalY - self.Position.Y)
Then the size formula would look something like:
Constrain Attribute: self.size.width To: 15+(self.InitialDistance - magnitude(self.finalX - self.Position.X , self.finalY - self.Position.Y ))*((40-15)/self.InitialDistance )
Works perfectly, thanks
Website » Twitter » Facebook » Loaded Arts - Fun for thumbs.
Developer Blog » 08/01/2015 - Week 72 – Apple, the great dictator…
But when I do this, the object does not draw at all.
It appears and scales (inverse to how I want it to) when there is no additional math involved, but as soon as I try to modify that magnitude calculation with any other calculations, it just stops working entirely.
Suggestions welcome. This is a polish feature, and not crisis-worthy, but I would really like to know why it is not working.
What are you doing when you "try to modify that magnitude calculation"?