negative Angular Velocity / Rotation issue

RondoRocketRondoRocket Member Posts: 411
edited June 2014 in Working with GS (Mac)

Attached a test file made with the latest Release Candidate.

I'm using a Constrain Attribute to smoothen out the rotation of an actor based on the rotation of another actor using this code: self.motion.angular.velocity To: self.Ease *( game.Rotation - self.Rotation )

The problem is I seem to be getting a weird spinning issue with the orange actor each time is does a full revolution.

Just curious if any of the math wizards here have a solution or suggestion.

Thanks!

Comments

  • daaddddaaddd Member Posts: 116

    can you specify wich attribute is integer/angle/index?

  • RondoRocketRondoRocket Member Posts: 411

    I'm going to put together a test project and see if I get the same results… if so I'll post it. Thanks for the help!

  • RondoRocketRondoRocket Member Posts: 411
    edited June 2014

    Attached a test file to my original post at the top. It was made using the latest Release Candidate. The orange actor is the issue, you can see once it does a full revolution it does a spin. I'm assuming it's happening when it reaches 360 and resets to 0?

    Thanks for any help.

  • colandercolander Member Posts: 1,610
    edited June 2014

    I can see it is doesn't like it when game.2Rot and self.Rotation rollover from 359 to 0 in Actor 3. There is a period between Actor 2 resetting to 0 and before Actor 3 resets to 0 when these values are vastly different which causes the actor to rotate. Maybe you could try and find a way to keep it incrementing instead of resetting to 0. I think creator would regard 360 degrees as 0 degrees 361 as 1 and so on.

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @RondoRocket said:
    Attached a test file to my original post at the top. It was made using the latest Release Candidate. The orange actor is the issue, you can see once it does a full revolution it does a spin. I'm assuming it's happening when it reaches 360 and resets to 0?

    Thanks for any help.

    I'm not sure what context this is being used in - so my solution might not be right for you - but I'd be tempted to simply copy the motion of the purple actor to the orange actor and then offset the angle that sin and cos are operating on . . .

    Also when matching the rotation of an object to a circular path (to keep it aligned to the path) I usually just copy the speed of the actor instead of using VectorToAngle - we already know the speed the object should be rotating at so it seems a little cruel to make GameSalad calculate a value we already know, I'm a big fan of making GameSalad (and your end device's processor) do as little work as it needs to.

    So for the purple actor I'd do this:

    Constrain X to 100*cos( self.Time *100)+ game.1X
    Constrain Y to 100*sin( self.Time *100)+ game.1Y
    Constrain Rotation to self.Time *100
    

    And then simply do the same for the orange actor but with an offset on the angle:

    Constrain X to 100*cos((self.Time *100)+12)+ game.1X
    Constrain Y to 100*sin((self.Time *100)+12)+ game.1Y
    Constrain Rotation to (self.Time *100)+12
    

    I used 12° as it matches what you currently have, but you can of course stick whatever you need in there, doing it this was gets rid of a few attributes and unneeded calculations . . . . . but like I say without knowing how this stuff works in your actual game it might not be suitable ?

    Let me make a quick demo . . . back in a minute . . . . .

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

    Demo as described above:

    https://www.mediafire.com/?tc2caq368btj9cc

    Demo as your original, but replacing angular velocity with constrain rotation:

    https://www.mediafire.com/?37m3mdyv8ub7gk6

Sign In or Register to comment.