# How do i make the spawn timing and velocity of actor ratio 1:1 ????

Member Posts: 74
edited December 2014

Background info:
I have a timer that spawns out an actor every 2 seconds at the top of the screen. The actor would then (move to) at the speed of 60 to (self.position.x,-40) all the way down. so for instance, the distance between 2 actors would be 80.

**Goal: **
What i want to do is to ensure the distance between 2 actors stays at 80 but i want to increase speed of the actor gradually to 90,100,110 as time goes by. what should i do?

**What i have done so far: **
Game attributes: integer Velocity 80
real Timing 2
i set up a timer to constrain both Velocity and Timing every second
game.Timing to game.Timing-0.125
game.Velocity to game.Velocity+5
but the only changes i see is that the actors move faster and faster by the spawn timing is the same. It stays at 2 seconds.

Here is a test project uploaded into dropbox, please assist me thanks guys!!
https://www.dropbox.com/s/y41g7yd7x2718pe/test.zip?dl=0

• Member Posts: 1,610

• Member Posts: 74
edited December 2014

@colander

i have placed the test project into dropbox. Please assist me

https://www.dropbox.com/s/y41g7yd7x2718pe/test.zip?dl=0

• Member, PRO Posts: 353

just give the actor a movement function - don't use a game attribute.

linear velocity Y.... if you want it to speed up use acceleration

• Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,926
edited December 2014

I take it you're using a PC?

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Member Posts: 74

@jorkos

I cant use acceleration because it would make the actors too far apart (http://i.cubeupload.com/QByJ8w.png)
The ideal distance that i want is this (http://i.cubeupload.com/3Q2n0x.png)

• Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,926

I don't understand the point of game.Timing since you aren't actually using that attribute for anything else, but the problem here is that if you increase the speed of an actor, it will move away from the spawn location faster, thereby increasing the distance between actors.

Here's my thinking: every second, you increase velocity by 5 which means that the actors move 5 pixels further away from the spawner. So you would need to decrease the spawn delay by 5/game.velocity every second.

I made you a demo with that method but as you'll see it's not perfect.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Member Posts: 74

@tatiang
Awesome! Its perfect, exactly like how i wanted it to be. Thank you so much!
But there are 2 things which i do not understand.

1)Why do we have to set self.initialVelocity to game.Velocity?
2)Why do we have to set self.timeStamp to game.time? Cant we just use game.time?

Sorry for the trouble and thank you so much for your help!