Am I completely crazy now? Help needed please.
GuaveMedia
Member, PRO Posts: 1,262
Hey guys,
well I have been without sleep for more than 20 hours now. Working on our new game version I am tired as hell and I have a problem. I am trying to rotate a object constrained to the touch position on the screen. The angle should be from 20 to 160 degrees. I tried a lot of things and it never works, sometimes the object roates a 360°.
So I used, when touch count=1
rotate to position
X (mouse position X, 160)
Y (mouse position Y, 20)
I can't see the problem right now, maybe I am too tired, any help for now would be awesome, then I can head out for bed and some sleep.
Thanks and cheers,
Alex
well I have been without sleep for more than 20 hours now. Working on our new game version I am tired as hell and I have a problem. I am trying to rotate a object constrained to the touch position on the screen. The angle should be from 20 to 160 degrees. I tried a lot of things and it never works, sometimes the object roates a 360°.
So I used, when touch count=1
rotate to position
X (mouse position X, 160)
Y (mouse position Y, 20)
I can't see the problem right now, maybe I am too tired, any help for now would be awesome, then I can head out for bed and some sleep.
Thanks and cheers,
Alex
Comments
When touch is pressed;
-->constrain self.position x to game.mouse position x
-->constrain self position y to game.mouse position y
-->Rule;
when self.rotation = 20
---->interpolate self rotation to 160
--> Rule;
when self.rotation = 160
----> interpolate self. rotation to 20
But I'm a little unsure on what you're trying to acheive. Are you after the object to constantly rotate, ie, rotate to 20, the back to 160 and then repeat (What I've portrayed above), or something else?
The principle is like a canon for example. Actually that's probably the best example for now. Just imagine rotating a canon from angle 20 to 160 constrained to the mouse position on the screen.
Thanks
But if it is not a multi-touch game(like for a desktop app)...
Constrain self.Rotation to min(160,max(20,vectorToAngle(mousePostionX-self.Position.X, mousePostionY-self.Position.Y)))
Is that something like you were looking for?
When touch is pressed,
Rotate to angle;
VectorToAngle(game.mouseposition.x - self.positionx, game.mouseposition.y - self.position.y)
AWESOME Thank you so much but also @iCreationZ for your help
I am going to bed now, definitely some sleep needed here, see ya tomorrow guys