Grow actor with constrained position offset.
Hi guys. I have a problem. I have an actor that grows while a certain attribute is true at a random point selected from a set of points. I need a specific point on the edge of the actor to constrain to the point of origin, so that the actor appears to grow away from the origin rather than grow from the center. One complicating factor is that the actor also spawns at a random angle.
So essentially what I need to do is constrain a point exactly half of the width (which is constantly changing) from the center position of the spawned actor, at the current angle, and x and y attribute defined by the random point selection. Uggh.
Any help?
So essentially what I need to do is constrain a point exactly half of the width (which is constantly changing) from the center position of the spawned actor, at the current angle, and x and y attribute defined by the random point selection. Uggh.
Any help?
Comments
For example, suppose I have 2 actors whose name is "A" and "B", and I have a third actor (self) that I wanted to grow between the two. (And I was using the instances in the scene.) The behaviors would look like this:
Change Attribute: self.Size.Width To: magnitude( scene.Background.A.Position.Y - scene.Background.B.Position.Y , scene.Background.A.Position.X - scene.Background.B.Position.X )
Change Attribute: self.Position.X To: ( scene.Background.A.Position.X + scene.Background.B.Position.X )/2
Change Attribute: self.Position.Y To: ( scene.Background.A.Position.Y + scene.Background.B.Position.Y )/2
Change Attribute: self.Rotation To: vectorToAngle( scene.Background.A.Position.X - scene.Background.B.Position.X , scene.Background.A.Position.Y - scene.Background.B.Position.Y )
Hope this helps,
RThurman
___________________________________________________________________________
I'm teaching an online programing course go here to find out more!!! http://gamesalad.com/forums/topic.php?id=31505
Constrain Att: self.position.x to (game.origin.x)-((self.size.width)*.5)
with no change to y as in this case it is just a horizontal actor growing from right to left. The problem I am having is having the position change based on the same angle and making the distance between "self.position" and "origin" change proportional to 1/2 of the width of the "leaf".
Thanks for your help!
Change Attribute: self.Rotation To: random(-90,270)
Constrain Attribute: self.Position.X To: game.origin.x+(( self.Size.Width *.5)*cos( self.Rotation ))
Constrain Attribute: self.Position.Y To: game.origin.y+(( self.Size.Width *.5)*sin( self.Rotation ))
Then you can 'grow' self.Size.Width however you want.
Also, the 'leaf' does not 'grow' left or right because of the addition sign. It grows to the left or right depending on the angle. So angles between 91 and 270 grow it to the left. And angles between 89 and -90 grow it to the right.
Hope that helps
RThurman