I want my actor to move in a circular path

Hii,
I want my main actor to move in a circular path, like if left side of the screen is pressed actor should move in a clock wise circular path and vice versa. Pls help me....

thanks

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited October 2016

    The easiest /most flexible way to do this would be to use a separate controller actor.

    Make a 'controller' actor, throw it into the scene somewhere, it can be invisible or off to one side so you don't see it, or even make its dimensions 0,0 . . . etc etc . . . basically you don't need to see it in the actual game.

    Set up a rule where your left and right screen presses rotate this controller actor. For example . . . (landscape iPad screen sizes used) . . .

    When mouse button down
    --When mouse X position > 512
    ----Rotate CW
    --Otherwise
    ----Rotate CCW

    Ok, so now you have a little controller actor that rotates CW or CCW depending on which side of the screen you press.

    Now in your main actor, the one you want to move in a circular path, give it these three behaviours . . .

    Constrain X to Radius *cos(controller's rotation)+main actor's X centre
    Constrain Y to Radius *sin(controller's rotation)+main actor's Y centre
    Constrain Rotation to controller's rotation

  • SocksSocks London, UK.Member Posts: 12,822

    example file attached . . . click/touch left or right to move . . .

  • blackmoroiblackmoroi Member Posts: 28
    edited October 2016

    thanks for the reply, This is what i need but my actor should move in a straight path if we are not pressing on the screen. To be more specific the actor should follow a tangential path when screen is not pressed. Pls help me

    http://images.tutorvista.com/cms/images/83/tangential-acceleration-image.png

  • SocksSocks London, UK.Member Posts: 12,822

    @blackmoroi said:
    thanks for the reply, This is what i need but my actor should move in a straight path if we are not pressing on the screen.

    Lol.

  • -Timo--Timo- Member Posts: 2,313

    move
    direction 0 relative to actor
    speed 300 or whatever

    if mouse button is down
    rotate clockwise
    speed 200 or whatever

Sign In or Register to comment.