Am I completely crazy now? Help needed please.

GuaveMediaGuaveMedia 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

Comments

  • iCreationZiCreationZ Member Posts: 158
    What about...

    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?
  • GuaveMediaGuaveMedia Member, PRO Posts: 1,262
    @iCreationZ

    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 :)
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    If you are using touch count, it will not be specific to the first touch in a multi-touch scenario. i.e. if you touch the screen in 2 positions and then release the first, then it will say touch count = 1, but the changing attributes will be for touch #2.

    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?
  • iCreationZiCreationZ Member Posts: 158
    edited March 2013
    If you are trying to have an object that points towards the mouse, but only when touched I'd recommend:

    When touch is pressed,
    Rotate to angle;
    VectorToAngle(game.mouseposition.x - self.positionx, game.mouseposition.y - self.position.y)
  • iCreationZiCreationZ Member Posts: 158
    Right, then see @CodeMonkey's example! He's fairly good at this sort of stuff!
    ;)
  • GuaveMediaGuaveMedia Member, PRO Posts: 1,262
    @CodeMonkey

    AWESOME :D 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 :)

  • iCreationZiCreationZ Member Posts: 158
    I-) I-)
Sign In or Register to comment.