How to interact with an orbiting object?
alexlaptev
Member Posts: 12
Hi guys!
I am an absolute beginner in GameSalad, but I fell in love with it at first sight (as I am not a programmer, but a graphic designer).
I started doing one game, and immediately ran into a problem whose solution I can't find by myself, and I can't also find the thread that discuss it.
The task looks simple - The rocket rotates around the planet at a given speed. I want to add the following functionality: when a player pushes the rocket with his finger, it speeds up its rotation in a given direction, depending on the speed of finger slide (but not changes the rotation radius, even a bit). But after some time speed slows down to default.
I tried to customise the Tshirtbooth's tutorial for orbital rotation, tried the rotate behaviour with dynamic speed affected by linearvelocity, but nothing works the way I want it.
The community looks very friendly. Be easy, it is my first post. Thanks a lot in advance for any tips.
Cheers.
I am an absolute beginner in GameSalad, but I fell in love with it at first sight (as I am not a programmer, but a graphic designer).
I started doing one game, and immediately ran into a problem whose solution I can't find by myself, and I can't also find the thread that discuss it.
The task looks simple - The rocket rotates around the planet at a given speed. I want to add the following functionality: when a player pushes the rocket with his finger, it speeds up its rotation in a given direction, depending on the speed of finger slide (but not changes the rotation radius, even a bit). But after some time speed slows down to default.
I tried to customise the Tshirtbooth's tutorial for orbital rotation, tried the rotate behaviour with dynamic speed affected by linearvelocity, but nothing works the way I want it.
The community looks very friendly. Be easy, it is my first post. Thanks a lot in advance for any tips.
Cheers.
Answers
http://forums.gamesalad.com/discussion/comment/328264/#Comment_328264
I used that principle with an axis, set the default angularvelocity to an axis (rocket follows it rotation), made a dummy object with a throw interaction, which is attached to the same position as rocket and rotates together with it. Than I made the following: when the dummy is touched, rotation of the axis is calculated as vectortoangle direction to dummy (and dummy is no more attached to rockets position); when dummy is thrown, angular velocity is calculated as abs(linearvelocityx)+abs(linearvelocityy) of the dummy (dummy is reattached to rocket after throwing). After I just made a rule that checks if angularvelocity is bigger or smaller than a defaut velocity and adjust it slowly to defailt.
The only problem is that the rocket moves after throwing only one direction (positive "abs" velocities). I will really appreciates some tips how to solve that problem.
In the 'dummy' actor, get rid of the "abs()" stuff. It should be:
Constrain Attribute: game.sunVelocity To: self.Motion.Linear Velocity.X+self.Motion.Linear Velocity.Y
Then in the 'sun' actor, get rid of the last two rules and replace them with the following rule:
When _ANY_
-- game.sunVelocity > game.sunVelocityLimit
-- game.sunVelocity < -game.sunVelocityLimit
---- Constrain Attribute: game.sunVelocity To: game.sunVelocity *.99
There are several things you can do to simplify the setup. (But perhaps that's what you are after in your other thread.)
http://www.mediafire.com/download.php?1u4yb0vskfd9rvx