Spawn actor and control on touch pressed
jon2s
Member Posts: 40
Just curious if anyone has any ideas for doing the following. On screen touch spawn actor at press point. While still touching the screen constrain the spawned actor to the touch location. On release, actor is alive and well. Next touch the same thing happens... spawn an actor and constrain to touch location.
The problem I'm having is first touch spawns the actor, but you have to touch a second time to control the actor that was spawned.
The problem I'm having is first touch spawns the actor, but you have to touch a second time to control the actor that was spawned.
Comments
Create a custom game attribute called "screen-is-touched" or something. A boolean variable set to "false" initially. Create another actor attribute called "this-is-new-actor"... this boolean variable could be set to "true" in its initial state. When the user touches the screen, "game.screen-is-touched" is set to "true"... otherwise revert to "false". When the actor is spawned, you create a Rule that says:
`IF "self.this-is-new-actor" is "true" AND "game.screen-is-touched" is "true" THEN constrain actor to touch X and Y position`
When the touch is released, BOTH "game.screen-is-touched" and "self.this-is-new-actor" would be set to "false". This would free up the current actor for the next. actor to be spawned and active; it would also tell GS that the same touch is not active, thus don't constrain the actor to that touch point.
Anyway, give it a try... again, this is late-night thinking and maybe not very clear or even sensible, but it might work...
In the spawned Actor, have a Rule setup like this:
Rule
When all conditions are valid:
game.Mouse is Down
-----Constrain self.Position.X To: Mouse.X
-----Constrain self.Position.Y To: Mouse.Y
As soon as you lift your finger, it will no longer be constrained.
(Mouse will translate to a single Touch automatically on the device)