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

Just started using Construct 2? Post your questions here

Post » Tue Sep 23, 2014 2:21 am

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.
B
3
Posts: 3
Reputation: 181

Post » Tue Sep 23, 2014 2:30 am

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, :).
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Tue Sep 23, 2014 7:39 pm

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 do not have the required permissions to view the files attached to this post.
B
3
Posts: 3
Reputation: 181

Post » Tue Sep 23, 2014 7:43 pm

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.
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
13
S
4
Posts: 303
Reputation: 1,705

Post » Tue Sep 23, 2014 7:44 pm

I just figured that out. Lol.... thanks!!! It works when you do that....
B
3
Posts: 3
Reputation: 181

Post » Wed Sep 24, 2014 6:17 am

@rpclarke Glad that the solution worked for you. Good luck with the rest of development, :D!
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008


Return to Beginner's Questions

Who is online

Users browsing this forum: vslk and 0 guests