Rotation Advice Needed
Hi
I'm moving a car along an x axis with swipes and want the car to rotate/tilt the angle you've swiped based on the distance you've swiped. If you've swiped only a little distance from the left side of the car it will tilt a little to the left, and if you swipe quickly for a longer distance the car tilts a lot more to the left. And likewise for right swipes.
I've got the left swipes working and the tilting is working perfectly, but when it tilts right it spins around completely, and probably happens at the end of the interpolate duration of 0.1. I'm using Interpolate to rotate the car and it seems to be treating any angles less than 0 as a complete rotation and spins the car right round rather than moving -5 or -10 degrees from 0.
This is my left angle formula
(10/100)*(( game.Screen.Size.Width /100)*( game.Car X - game.Touch X ))
This is the formula I'm using for right turns
-((10/100)*(( game.Screen.Size.Width /100)*( game.Touch X - game.Car X )))
It does tilt right but quite often it spins around a full 360 degrees until game.Touch X = game.Car X which is when the angle is 0 and the car is facing straight up.
Does anyone have an idea how I can rotate an actor right (minus numbers) using interpolate without it doing complete spins please?
Here's a video of the problem in action
I'm moving a car along an x axis with swipes and want the car to rotate/tilt the angle you've swiped based on the distance you've swiped. If you've swiped only a little distance from the left side of the car it will tilt a little to the left, and if you swipe quickly for a longer distance the car tilts a lot more to the left. And likewise for right swipes.
I've got the left swipes working and the tilting is working perfectly, but when it tilts right it spins around completely, and probably happens at the end of the interpolate duration of 0.1. I'm using Interpolate to rotate the car and it seems to be treating any angles less than 0 as a complete rotation and spins the car right round rather than moving -5 or -10 degrees from 0.
This is my left angle formula
(10/100)*(( game.Screen.Size.Width /100)*( game.Car X - game.Touch X ))
This is the formula I'm using for right turns
-((10/100)*(( game.Screen.Size.Width /100)*( game.Touch X - game.Car X )))
It does tilt right but quite often it spins around a full 360 degrees until game.Touch X = game.Car X which is when the angle is 0 and the car is facing straight up.
Does anyone have an idea how I can rotate an actor right (minus numbers) using interpolate without it doing complete spins please?
Here's a video of the problem in action

Best Answer
-
RThurman Posts: 2,881
@KevinCross -- It good that you have it sorted out and working how you like. I hope you don't mind me sharing some tips and ideas for others who might view this thread.
First, I'd suggest to make any graphics to always point to 0 degrees. In GameSalad that is straight to the right ---->. Then things can rotate based on their true starting point. So, for example, one would make a car graphic to point to the right (0 degrees) before bringing it into an actor (that points to 0 degrees by default.) Then one can manually rotate it to 90 degrees (straight up) in the scene.
Next, its probably best to set up some kind of difference measure and then base the actor's movements based upon the difference between the desired state and its current state. For example, you want to base things off of the difference between the actor's X and the mouse's X. In general the equation would be: difference = mouse.X - actor.X
Then it becomes easier to use some general algorithms for getting things to move. They could look like this:
When mouse down
-- Constrain Attribute: self.difference To: game.Mouse.Position.X-self.Position.X
-- Constrain Attribute: self.Position.X To: self.Position.X +(.075*self.difference )
-- Constrain Attribute: self.Rotation To: 90-(.5*self.difference )
Note: Self.difference is a 'real' attribute. The .075 and the .5 can be adjusted to get the effect you are after. They are dampeners that help 'soften' the movements.
Anyway, I hope these ideas might be useful.
Answers
EDIT: It flips when the angle is greater than -1 i.e. -0.4 or -0.7 etc. A bit weird but automatically setting the angle to 0 if it's greater than -1 sorts it. I'm confident it's working how I want it to now.
I'm guessing with your example I'd still need to set up a block for each left and right, as left would be self.Position.X - mouse.Position.X and right would be the reverse sum mouse.Position.X - self.Position.X
I'll give the graphics pointing to the right thing a go too.
Also no need to set up left and right rules. It just rotates based upon mouse.X.
In my example I have an invisible actor used as a tracking pad so that it won't follow the mouse in the whole window but you've helped enough to get the best of both worlds.
Thanks for your help!