Move To, Accelerate Toward Help
I'd like to create a vacuum effect. I have a vacuum actor and a ball actor. When I press a button the ball actors move toward the vacuum however they all move at the same speed/velocity toward the actor. I'd like actors far away to move more slower to the vacuum and actors very close to move quickly. If possible I'd like to add another rule that if the button is pressed longer the stronger the vacuum pulls the ball actors to it.
So far this is what I have (not much)!
BALL ACTOR:
Change Attribute
self.dist.from.vacuum to self.Position.X - game.vacuum X
Change Attribute
self.dist.from.vacuum to self.Position.Y - games.vacuum Y
Accelerate
Direction 270
Acceleration 300
Relative to Scene
(
Rule when game.button.pressed is true
Move To
game.vacuum X
game.vacuum Y
Relative to Scene
Speed 300
Accelerate Toward
game.vacuum X
game.vacuum Y
Relative to Scene
Speed 300
)
Rule when actor collides with vacuum
Destroy actor
So far this is what I have (not much)!
BALL ACTOR:
Change Attribute
self.dist.from.vacuum to self.Position.X - game.vacuum X
Change Attribute
self.dist.from.vacuum to self.Position.Y - games.vacuum Y
Accelerate
Direction 270
Acceleration 300
Relative to Scene
(
Rule when game.button.pressed is true
Move To
game.vacuum X
game.vacuum Y
Relative to Scene
Speed 300
Accelerate Toward
game.vacuum X
game.vacuum Y
Relative to Scene
Speed 300
)
Rule when actor collides with vacuum
Destroy actor
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
VACUUM ACTOR
Change Attribute
game.vacuum.x to self.position.x
Change Attribute
game.vacuum.y to self.position.y
BALL ACTOR
Rule
When attribute game.button.pressed = true
Constrain Attribute
self motion linear velocity x
-(480-magnitude( self.Position.X - game.vacuum.x , self.Position.Y - game.vacuum.y ))*.6
self motion linear velocity y
-(320-magnitude( self.Position.X - game.vacuum.x , self.Position.Y - game.vacuum.y ))*.6
Instead of the balls going toward the vacuum actor they go to the bottom left hand corner of the screen. I want the vacuum actor to be anywhere on the screen. I thought the problem was due to constrain attributes having the 480x and 320y values in front magnitude but taking them out only sends the balls toward the upper right hand of the screen not toward the actor.
I can get it working where the balls go to the vacuum using the line below but they don't have any velocity (ones closer move faster, farther slower).
Accelerate Toward game.vacuum.x and game.vacuum.y relative to scene, acceleration 300
How can I get velocity and them going toward the vacuum at the same time???
Thanks!