slider controls actor in circle movement

GnarlyGnarly canadaMember Posts: 840

So I would like to use a slider to control (1) the position of an actor (B) on a circle........

https://www.dropbox.com/s/dcpjrg4neq5or8i/Controls circle.png?dl=0

Moving the slider right or left would move the orbit actor right and left but not in a straight line..... It moves left and right constrained along the circle. I think the diagram explains it better.

Thanks T shirt booth for his actor moving in a orbit.

The code for the orbiting actor:

Constrain:
Self.positionX.... 100cos(Self.time20%360)+game.Sunx
SelfpositionY...... 100sin(self.time
20%360)+game.SunY

So obviously Self.time will provide a constant orbit movement around the circle. Ive been playing with attributes and linking them to the slider...... I get erratic movements to nothing.........

Am I on the right track here???? pun intended.

Thanks

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    @gattoman said:

    The code for the orbiting actor:

    Constrain:
    Self.positionX.... 100cos(Self.time20%360)+game.Sunx
    SelfpositionY...... 100sin(self.time
    20%360)+game.SunY

    So obviously Self.time will provide a constant orbit movement around the circle. Ive been playing with attributes and linking them to the slider...... I get erratic movements to nothing.........

    Am I on the right track here???? pun intended.

    Thanks

    No real need for the %360 part (it's not like you will every run out of degrees in an angle)

    100 *cos (Self.time *20)+ game.SunX
    100 *sin (Self.time *20) + game.SunY

    The angle that cos and sin operate on are within the brackets, so you need to replace this with the X position of your slider . . .

    100 *cos (slider X position)+ game.SunX
    100 *sin (slider X position) + game.SunY

    You might want to divide or multiply or offset the slider's value to adjust the interaction, just use some basic maths . . . for example . . .

    100 *cos (slider X position * 10)+ game.SunX
    100 *sin (slider X position * 10) + game.SunY

    . . . or . . .

    100 *cos ((slider X position *10)+180)+ game.SunX
    100 *sin ((slider X position *10)+180) + game.SunY

    etc etc.

  • GnarlyGnarly canadaMember Posts: 840

    Thanks socks I will give it a go tomorrow!!

Sign In or Register to comment.