Spawning moving objects
I'm currently making a flappy-bird style game. For level 2 I want moving obstacles to be spawned, i.e. the obstacles (tubes) move up and down as they comes toward you. For level 3 I would like the obstacles to move in a pendulum movement towards the main character. I have succeeded in getting these movements to work, however when it comes to spawning them they will not move.
I've been looking up a lot of forums but cannot find a way around this. I did find this statement: "The actors are locked in place since they need and x or y start/reference point. So when you tell it to spawn it will only spawn in that location & the move behavior does not function". Is there any way around this that I can get moving obstacles coming towards me or should I admit defeat? Any advice is greatly appreciated!
Comments
A spawned actor's rules perform the same as if the actor had been placed on the scene originally. Therefore, a Move behavior or anything else should still work.
How do you have the rules set up?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Set up for the up/down obstacle:
Self.Motion.Linear Velocity Y To -self.mySpeed (mySpeed is an integer 200)
To move up:
When attribute self.position.Y ≤ self.myMin, change attribute self.Motion.Linear Velocity.Y to self.mySpeed
Move down:
When attribute self.positionY ≥ self.myMax, change attribute self.Graphics.Flip Vertically to 0, Change attribute self. Motion.Linear to -self.mySpeed.
When attribute gameplaying is true, move 180 degrees relative to actor, additive
Set up for the controller which spawns the goal:
When game playing is true: ever random 1-3 seconds (run to completion), spawn actor goal in front of actor, direction 0, position 0 relative to actor
Set up for the goal which spawns the obstacle
Change attribute self gap to random (70,250)
When attribute game.playing is true: move direction 180, speed 200 relative to actor additive
Spawn top obstacle in front of actor direction 0, relative to actor. Position self.position.x, self.Gap+220 relative to scene
Spawn bottom obstacle in front of actor, direction 0 relative to actor. Position: self.Position.x, self.Gap-220 relative to scene.
This all causes obstacle to move up and down on the spot but not towards character.As as my character does not move forward, the obstacle will never reach character
If i put this function into obstacle: direction 180, relative to actor additive, speed: game.obstacle speed : the controller just spawns still obstacles
Random(1,3) in a timer won't work . . . well it will work as it should - it will select either 1, 2 or 3 and then spawn actors with that interval, so if it selects 3, it will spawn actors every 3 seconds . . . but it won't spawn actors at random intervals.
The rest of the arrangement sounds very complicated for what is a simple task, maybe I don't understand what you are trying to achieve, but why does the controller spawn a goal and the goal then spawn the obstacles, could the controller not simply spawn the obstacles ?
Maybe game.obstacle speed is set to 0 ?
Sorry I may not be explaining very well, I've included a link of the game at present:
As you can see the obstacles are animated rather than actually moving which is not ideal. As this is level 2 we were hoping to the mine would approach in a move up and down movement to make game more difficult, and for level 3 in a pendulum movement as shown here:
I've got the motions working as shown, but when it comes to spawning them everything goes a bit wrong!
It's not clear what the issue is, it's not even clear what the question is !
Ok, so basically, I want the water-mine obstacles from video 1 (which are coming towards the panda to kill him) to move up and down as they approach, as in video below, instead of animating! So the panda must navigate between these moving obstacles, rather than moving between static animated obstacles
So, you want an actor to move up and down while moving left ?
I'd simply use the Move behaviour to make the actor go left.
Yeah exactly! But when I use the move behaviour (180 degrees relative to actor additive), it doesn't work, the obstacle stays static. While spawning the object won't move up and down while moving left. Am I missing something really obvious here?
I feel like the obstacle is confused because it is being told to move both up and down, and also being told to move over, so it can only do one or the other, hence my problem
Do you want it to move like a sin wave?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
No I would like it to move up and down on its axis, but i want axis to move towards character
When I place an actor into a scene - and that actor have a Move behaviour set to 180°, the actor moves left, but this doesn't happen for you ?
Maybe game.obstacle speed is set to 0 ?
Actors in GameSalad don't get 'confused', although this does sound very complicated for what is a simple task, maybe I don't understand what you are trying to achieve, but why does the controller spawn a goal and the goal then spawn the obstacles, could the controller not simply spawn the obstacles ?