Advance question with actor rotation functions?
Hello
I have an actor that rotates using this Rule:
ChangeAttribute:
vectorToAngle( game.Touches.Touch 1.X - self.Position.X , game.Touches.Touch 1.Y - self.Position.Y )- self.Rotation
Constrain Attribute:
vectorToAngle( game.Touches.Touch 1.X - self.Position.X , game.Touches.Touch 1.Y - self.Position.Y )- self.offsetAngle
So this makes it rotate to the point where to mouse or touch is straight away. So if the actor is at 180 degrees and i touch 270, it automatic rotates to 270. I don't want that. I need it to rotate normally to the touch angle despite where about the touch location is. After the touch location is identified then the actor can rotate according to how far from the original touch. I hope i am making sense.:)
Second question if the above is simple,
How would i make it so that once i release touch the actor will rotate for a little bit instead of coming to a complete stop straight after i release touch?
If you don't understand i can email a diagram explaining exactly!
Thanks
Elfizm
I have an actor that rotates using this Rule:
ChangeAttribute:
vectorToAngle( game.Touches.Touch 1.X - self.Position.X , game.Touches.Touch 1.Y - self.Position.Y )- self.Rotation
Constrain Attribute:
vectorToAngle( game.Touches.Touch 1.X - self.Position.X , game.Touches.Touch 1.Y - self.Position.Y )- self.offsetAngle
So this makes it rotate to the point where to mouse or touch is straight away. So if the actor is at 180 degrees and i touch 270, it automatic rotates to 270. I don't want that. I need it to rotate normally to the touch angle despite where about the touch location is. After the touch location is identified then the actor can rotate according to how far from the original touch. I hope i am making sense.:)
Second question if the above is simple,
How would i make it so that once i release touch the actor will rotate for a little bit instead of coming to a complete stop straight after i release touch?
If you don't understand i can email a diagram explaining exactly!
Thanks
Elfizm
Best Answers
-
kinzua Posts: 554
@Elfizm hey there.. there are many ways to work around this situation..
1. Dont use constrain.. instead use a variable to detect touch as and when it happens.. and then interpolate its rotation. This might not help entirely either.
2. You can constrain the rotational velocity of the actor to
when touch is down
((current angle-newTouchAngle)*10)
otherwise
self.rotSpeed= self.rotSpeed*0.95
The second option will work for you. Hope that helps.
Answers
So what I have done is recorded where the first touch is and found the angle in regards to the main actor position, then constrain where the touch Is and find that angle to a different attribute.
Then first angle minus the constraining angle, I think this works well till the constraining angle reaches -180 in which it then jumps to 180. So hence now the rotation is going the other way instead of continuing the way it was rotating.
Any help?
So I guess this is a self trial and error time for me. I made it so an actor rotates according to the rotation between the first touch and the current touch, that all works fine.
So again, how would I be able to tell how fast the actor is rotating and put some kind if drag on it. The problem is that I am un sure how I can work out the value of rotation speed or make it have a slowing down effect, just like when you spin a wheel
Cheers
Elfizm
But I did have a solution for part of it and got some help from @socks which was really cool. Still working on it to have extra features that was explained to socks but it's not at the top of list right now.
What I am stuck on is how I can keep a minimum speed if let's say 30 to rotate but increase in relations to the players touch input. When I get to it again I will see what I am really doing and try and give full attention.
Thanks
Elfizm