Help...Spawn actor and Accelerate toward
hi there. I don't know if this is the right place to ask this question but i have a problem with a project i work and i'm kinda stuck...
I have an actor that spawns another actor. and i want that the spawned actor to move to the given coordonates (not every time are the same). the problem is when i touch the actor that spawns the other one it starts to move to that mouse click coord.
i use the rule to spawn the actor.
on the spawned actor i use accelerate toward game--touch pressed.x and y ------ and moving to the actor i pressed to spawn
then i used the actor to spawn another actor(not movable) that after 0.1 seconds to spawn the desired actor but still goes for the original mouse click.
So what i intend to do is when i touch an actor to spawn another one and stand still untill i touch another part of the screen and then to accelerate toward that coord.
Comments
Transfer the touch x and y positions to the spawned actor by using actor attributes. Create a boolean attribute in the actor you are spawning (not the actor with the Spawn behavior) called self.targetSet and set it to false/unchecked. Create two real attributes called self.targetX and self.targetY. Then use this rule:
When Mouse Button is Down AND self.targetSet is false
Change Attribute self.targetX to mouse.Position.X
Change Attribute self.targetY to mouse.Position.Y
Change Attribute self.targetSet to true
When self.targetSet is true
Accelerate Toward self.targetX self.targetY
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks i will use this method. I was thinking that i will need something like that....but i ignored that option...i thought of a simple solution.
Thanks again i will try it out and reply.
Since it will be an android game i will use touch positions x and y instead of mouse button is down.
I just tried this method but still doesn't work.The spawned actor starts to move when i touch inside the actor.
and what about an patrolling actor?
When the actor is spawned it starts to move on the x axe and so on until a given coord to accelerate to, then let the game physics do the job and when the actor stop moving to destroy itself (already done that )...That was my original idea but since i didn't came to a solution i made the other option that i asked for help.
Now since none of the solutions works i want to make the actor accelerate, to a given target while patrolling.
P.S. i have already the actor patrolling but not accelerate to....
Try using the move behavior instead of accelerate.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
"Mouse" just means any click or tap. If you use "If Touch is Pressed" it only triggers when you tap on the actor itself. "If Mouse is Down" triggers when any tap is registered on the device.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
This might help --
It works fine i had some rules messed up but now works great thx for the help.
I have a problem though, the project i work on is based on collisions/destroying scenery. So i have an menu that select what kind of tools to be used to destroy according to the lvl.
The menu actor spawns a ball in this case.
The ball when spawned should patrol from edge to edge on x axe of the scene.
When i choose where to hit i need the ball to accelerate to x,y from his actual x position until collide.
Now if the player will not give the precise point of collision but above or under? Then i need that ball to accelerate until collision.
The accelerate toward makes the ball to regress after collision.
I'm out of ideas i tried accelerate and move but those options only use x or y axes only not both, the move to stops when x,y reached(if player points a non collision point? the ball stops and nothing happens).
What do you want the ball to do when it collides with another actor?
1) Does the ball keep moving in the same direction as it started.
2) Does the ball bounce off the other actor and keep moving in the new direction?
3) Does the ball stop and never move again?
4) Does the ball stop movement? But will it start moving when another touch is made?
5) Does the ball blow up and disappear?
Well my idea is that when the ball collide will do damage to the actor it collides with (the ball will have a given damage) and then it will explode in tiny pieces (particles) then disappear.
i found an old thread with the same issue but i didn't get it.
http://forums.gamesalad.com/discussion/7893/set-velocity-towards-a-point
@RThurman can you give me a hand here?
This video should help you with part of it. This is how to measure the intensity of the impact.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Thanks @Lost_Oasis_Games
and how to keep accelerating past those x,y given coord