How do I make it look like the player sprite nudges object?

Get help using Construct 2

Post » Mon Apr 04, 2016 5:55 pm

Im working on a top down game and wanted some sprites/objects to just sit on screen unless the player collides with it. When the collision happens, I want the sprite to move out of the way just a bit, to look like the player kind of lightly kicked it out of the way. How would I go about doing something like that? Thanks for your time.
B
6
Posts: 30
Reputation: 310

Post » Mon Apr 04, 2016 8:15 pm

Try using a bullet behavior on the sprite, default 0 speed/gravity.

Condition: Sprite on collide with Player
Actions: Set Sprite bullet angle of motion to angle(player.x, player.y, sprite.x, sprite.y) //Maybe +180, I forgot if this will angle towards the player or away from the player off the top of my head.
Set Sprite bullet speed to 200 //Or whatever initial speed

Decay bullet speed:
Condition: Sprite bullet compare speed > 0
Action: Set Sprite Bullet speed to floor(sprite.bullet.speed/2) //Eased out deceleration, you can use sprite.bullet.speed-20 for linear deceleration for example. Best practice might be to add max(0,x) expression to constrain the speed so it does not go below 0.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Mon Apr 04, 2016 9:01 pm

Brilliant! I would never have thought of that but it's exactly what I was looking for. Thank you!
B
6
Posts: 30
Reputation: 310


Return to How do I....?

Who is online

Users browsing this forum: evillair and 9 guests