How do I make a car spin after it hits an oil spill

0 favourites
  • 6 posts
From the Asset Store
Template for a police car chase game, fully documented in comments and video
  • Hey Guys,

    Just learning the interface, and I am using the Driving Template provided in the free edition. I have been changing the game up, and my goal is to have have the car collide with an oil spill(another object) and then make it spin out of control.

    I can turn off the players controls, and I played with the rotate features a bit, but its not working as I would expect.. Like spin the car for 3 seconds...

    Thanks for any help.

  • You can do this effectively with animations. If you have an image editor such as Adobe Photoshop or GIMP you can make a nicer spin effect, but you can make a basic one (four points of rotation) within Construct 2's Sprite editor. Open the Sprite editor for your Car sprite and on the right of your screen will be an Animations window. Make a new animation called Spin. At the bottom of your screen is an Animation frames window, and here you want to make three duplicate frames by right-clicking the window and selecting Duplicate last frame. In each animation frame except the first (because it's your default facing), click the Rotate 90* button of your choice (either anti-clockwise or clockwise). Then on collision with the oil spill object, set the Player animation to be the Spin animation and set it to Play.

    If you want to disable player movement while the Car object 'spins', make a global variable (right-click anywhere in the Events window, just not on an event) where your movement controls are, place it above all movement events and call it movementAllowed and set it to be the Number type with a value of 0. Make a condition event that checks if movementAllowed is equal to 0 and move all your movement events inside. Beneath that condition event, add an event that checks if the Player Spin animation is finished (using Player -> On finished 'Spin'), add an event that sets movementAllowed to 0. Then, in your oil spill collision check, set movementAllowed to be 1.

    This should all set the game up so that when you hit an oil spill, your car spins and you cannot move until it stops spinning, .

  • So interesting thing, I created the animation in the sprite editor, just rotated the car around 90 degrees, but when I play the animation, each step in the frame ends up in a different spot on the screen, rather then the center where the car was.... Then stops, with the car object on another part of the screen, but you can drive around as if the car was in the middle of the screen. Funnier yet is that the sprite is still collidable...

    I see in another tutorial, that some people create an empty object and pin the sprite to it, is that what would fix this or is there a way to make this work without doing it that way?

    included the file so you can see what i mean....

    Thanks so much!

  • You might want to go into the sprite editor and make sure the origin point is in the center, or at least in the same place for each frame.

  • I just figured that out. Lol.... thanks!!! It works when you do that....

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • rpclarke Glad that the solution worked for you. Good luck with the rest of development, !

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)