How to make something rotate in place?

MetzoPainoMetzoPaino Member Posts: 195
edited April 2012 in Working with GS (Mac)
Hi everyone,

I imagine that this is pretty easy, but I just can't figure it out.

My game has falling objects using the move behaviour, and I want these objects to spin as they fall.

Any advice?

Best Answers

Answers

  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Have you tried to use the rotate behavior?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Constrain another actor to the falling object's position and have that actor rotate. Place the rotating actor above (or on a layer above) the falling actor. Another way to do this without affecting performance so much is to animate or change the image of the falling actor so that it appears to rotate even though it isn't rotating.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • PsychoticStudiosPsychoticStudios Member Posts: 101
    Use a rotate behavior. :D

    Also I would recommend using an accelerate behavior so the objects pick up speed as they fall. It just adds a bit more realism.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Maybe someone can help me with this, too. I have an actor that moves across the screen via a change velocity behavior but then is also affected by gravity using an accelerate down behavior. If I try to rotate the actor with a Rotate behavior, it gets all squirrely and doesn't follow the trajectory of the initial change velocity direction. How can I fix this?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2012
    @LiquidGameworks Yes, it does continually rotate. The problem is that any rotation on the actor affects its direction. I made a demo to illustrate this: http://dl.dropbox.com/u/19602014/Rotate with Gravity.zip

    In the demo, I have two identical actors but one actor has your interpolate rule turned on and one actor has it turned off. They both start from the same position at the top of the scene but they end up in different positions at the bottom of the scene.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • MetzoPainoMetzoPaino Member Posts: 195
    edited April 2012
    Have you tried to use the rotate behavior?

    Yes, it makes the object rotate around where it is spawned, I need it to "spin" as it falls.
    Use a rotate behavior. :D

    Also I would recommend using an accelerate behavior so the objects pick up speed as they fall. It just adds a bit more realism.
    I've tried the rotate to position and rotate to angle behaviours and they don't seem to help much, (unless I'm not using them correctly). I don't want the objects to accelerate, it isn't a realistic game, it's more like Tetris.
    Actually, if you change the velocity of the falling actor or change it's y position over time instead of using a Move behavior, you can just rotate it using the Rotate behavior. Scratch what I said before.
    I'll try this, but I think I chose to use a Move behaviour for a specific reason. (I'm finishing a project that I haven't worked on in months). Oh is it that velocity has a "speed up" time? Because that wouldn't do unfortunately.
    @tatiang Does the image need to continually rotate? If so, you can interpolate rotation. Something like Rule: If self.rotation=0 then interpolate self.rotation to 360. Changing the duration changes the speed.
    I thought this would work, but like the rotate behaviour it makes it rotate to widely, I need it to "spin" in place as it falls. I do need it to constantly spin though.

  • MetzoPainoMetzoPaino Member Posts: 195
    edited April 2012
    It seems like a combination of changing from Move to Velocity, and using Interpolate rotation has sorted it out. I'm still pretty sure that I chose against Velocity when I originally worked on this game though, but I can't remember why...

    Oh, and the Rotate behaviour now works as expected, so no Interpolate required. Unless it happens to be more efficient for some reason.
  • LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
    @tatiang @metzopaino

    Having just played with the file, i found an easy fix. I don't know if its something you can't use due to gameplay conditions, but in your velocity/acc behaviors, change relative to "scene". When I did that, they stayed together on the same course.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @LiquidGameworks Can't believe I missed that. Thank you, thank you, thank you, thank you, thank you! :D

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
    @tatiang No prob! Its always the little things, isn't it?
  • MetzoPainoMetzoPaino Member Posts: 195
    Ah, I need the objects to move down the screen using Move rather than Velocity, because when I pause the game I want them to freeze.
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Ah, I need the objects to move down the screen using Move rather than Velocity, because when I pause the game I want them to freeze.
    Then in the pause button you can change velocity to 0.


Sign In or Register to comment.