Spawn actor from main actor and move to touch
billpaterno
Member Posts: 26
I am trying to set up some behaviors so that when a button is pushed, a projectile actor spawns from my main actor, constrains its XY to the main actor until another point is touched on the screen...then I would like the projectile actor to move to the point touched.
Right now I have a boolean game attribute for spawning that is set to false. When the button is pushed, that attribute is set to true, which spawns a projectile actor from my main actor. Then in the projectile actor behaviors, I have two rules. One which contrains XY to main actor for .1 seconds (if spawn=true) and then another rule (move to) that follows the XY of the mouse. However, if I move the mouse around, the projectile follows the mouse until it hits the cursor.
Right now I have a boolean game attribute for spawning that is set to false. When the button is pushed, that attribute is set to true, which spawns a projectile actor from my main actor. Then in the projectile actor behaviors, I have two rules. One which contrains XY to main actor for .1 seconds (if spawn=true) and then another rule (move to) that follows the XY of the mouse. However, if I move the mouse around, the projectile follows the mouse until it hits the cursor.
Comments
set two constrain Attributes, one for the playerX and on for the playerY.
3 attributes, targetX, targetY, and a boolean: movingToTarget
and a Rule that says:
ALL
When the MOUSE button is DOWN
When movingToTarget is FALSE
Change Attribute: targetX to Mouse.PositionX
Change Attribute: targetY to Mouse.PositionY
Change Attribute: movingToTarget to TRUE
And another Rule
When movingToTarget is TRUE
MoveTo targetX,TargetY
What I have right now is the spawned actor with the following behaviors:
Constrain X, Constrain Y to PlayerX and PlayerY
Rule: When game.movingToTarget is true, move to game.targetX, game.targetY
For the button I have:
When ALL..mouse button down, mouse position inside, game.movingToTarget is false,
Change boolean game.Spawn to true
Change game.targetX and Y to game.Mouse.PositionX and Y
Change game.movingToTarget to true
And for the player actor I have:
When game.Spawn is true, after .5 seconds (timer), spawn actor
When I press the button, projectile spawns on top of player actor and tracks with him but the second click does not direct the projectile.
I know I am missing something stupid here.