GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Camera Rotation & Character Position

Hi GameSalad Community,

I need your help on this project. I want to create a rotating circular world with the character on top. I created a rotating world already using Change Attribute:

where:

Every = 0.001
{
(Change Attribute)
scene.Camera.Rotation = scene.Camera.Rotation +2
}

Everything is rotating. I made the camera rotate instead of the objects because it will be easier for me to create behaviours (like up and down behaviour, etc..) without adding a rotation behaviour to each actors and could cause complexity.

My problem is, I want the main character to retain its position at the top and not be affected by the camera or somehow change its position at the top.

What could be the possible solution for this?

Thanks!

Best Regards,
Synergy88Studios

Comments

  • SocksSocks London, UK.Posts: 12,822Member
    edited January 2014
    Every = 0.001
    (Change Attribute)
    scene.Camera.Rotation = scene.Camera.Rotation +2


    Doesn't this (above) rotate really fast ? I seems like it would rotate 360° in less than a fifth of a second ? Also could you not get rid of the timer and simply rotate the camera in real time (rather than discrete steps) ?

    For the actor at the top you could simply move him in a circular path travelling in the opposite direction to the world's rotational direction. Or maybe stick him on a non-movable layer ? Hard to really say without knowing what this actor is doing.
  • synergy88studiossynergy88studios Posts: 23Member, PRO
    @Socks

    Yes, it rotate quite fast. But I can still change this. I placed a Timer on it because it will be rotating endlessly. I'm not sure how to do it without placing a Timer.

    Oh Yes. Nice idea for the Actor. But even though I set the Actor as a Non-Movable Layer. It still rotates because of the camera itself is rotating. The actor will be set to jump and will travel on the rotating world. Imagine a clown on top of a ball.

    Just need to know some lines of codes that I can use to "constrain" the top position of the character.

    Thanks! :)
  • SocksSocks London, UK.Posts: 12,822Member
    edited January 2014

    @Socks

    Yes, it rotate quite fast. But I can still change this. I placed a Timer on it because it will be rotating endlessly. I'm not sure how to do it without placing a Timer.

    Constrain - self.rotation to game.time (or self.time) multiplied by some factor of your choice (depending on how fast you want it to go) . . . . something like that ?

    Oh Yes. Nice idea for the Actor. But even though I set the Actor as a Non-Movable Layer. It still rotates because of the camera itself is rotating.

    Whoops ! Yes, of course, you are right.

    The actor will be set to jump and will travel on the rotating world. Imagine a clown on top of a ball.

    Such a sad image . . and imbued with such dark pathos . . . are we not all clowns atop a never still ball, this ball we call life ? [falls off chair, drunk, and knocks himself out on a life-size cut-out of Dark Maul]

    constrain X to Radius*cos(game.time*SpeedOfRotation)+XCentrePointOfOrbit.
    constrain Y to Radius*sin(game.time*SpeedOfRotation)+YCentrePointOfOrbit.

  • synergy88studiossynergy88studios Posts: 23Member, PRO
    Gonna try this one. Thanks Man! *High-Five*

    I agree that we are all clowns in life. I'm not trying to disrespect clowns. But they are clowns aye and we are clowns? :) Haha.

    Thanks again man!
  • synergy88studiossynergy88studios Posts: 23Member, PRO
    @Socks

    I did not understand the

    XCentrePointOfOrbit and YCentrePointOfOrbit

    And for the Radius, you mean the radius of the Rotating World?

    Thanks in Advance.
  • SocksSocks London, UK.Posts: 12,822Member
    edited January 2014
    @synergy88studios

    We are getting an object to travel in a circular path, CentrePointOfOrbit is the centre point of that circular path.

    XCentrePointOfOrbit is the X position of the centre point of that circular path.
    YCentrePointOfOrbit is the Y position of the centre point of that circular path.

    I'd just use the X and Y coordinates of your rotating world as it lies at the centre of this circular path.

    The 'Radius' is how far an object is from the centre point of its circular path, make it whatever you like.

    Hope that helps.
Sign In or Register to comment.