When a bullet hit in the character.

For questions about using Classic.

Post » Tue Jul 07, 2009 10:48 am

Hello!

How to make that when a bullet hit in character, it throws him a little bit back? (in the opposite direction of bullet). Note,the character has 8Direction behavour.
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Tue Jul 07, 2009 11:56 am

I would try move at angle.
bullet: On collision between bullet and Sprite
> SpriteMove 10 pixels at (bullet 0 .Angle degrees)
Image ImageImage
B
169
S
50
G
169
Posts: 8,284
Reputation: 108,212

Post » Tue Jul 07, 2009 12:37 pm

newt Thank you! It works! :D
B
3
S
2
G
3
Posts: 146
Reputation: 1,567

Post » Tue Jul 07, 2009 1:22 pm

Remember to check for obstacles and such, or else the sprite might get shot THROUGH the wall. ;)
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,180

Post » Tue Jul 07, 2009 2:10 pm

yeah you wouldn't want yourself to move through walls :cry:
B
147
S
74
G
20
Posts: 1,786
Reputation: 22,527

Post » Tue Jul 07, 2009 2:15 pm

Yep
something like
bullet: On collision between bullet and Sprite
Sprite is not overlapping terrain.family
> SpriteMove 10 pixels at (bullet 0 .Angle degrees)

should work, you might even try offset.
Image ImageImage
B
169
S
50
G
169
Posts: 8,284
Reputation: 108,212

Post » Wed Jul 08, 2009 4:42 pm

You want to check that you're not being moved in to terrain - not that you aren't already in terrain :P 'Is overlapping at offset' can check that.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,746

Post » Thu Jul 09, 2009 10:28 am

Or you can move first, check for overlap, then move back... that would appear like bouncing off the wall (ouch).
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,180

Post » Thu Jul 09, 2009 10:42 am

Heh you must think like the bullet, be the bullet.
Image ImageImage
B
169
S
50
G
169
Posts: 8,284
Reputation: 108,212

Post » Thu Jul 09, 2009 10:33 pm

I thought about changing 8-direction speed and angle based on a small calculation to have physics-like reaction, but then realized that changing the angle would make the character turn.
So bleh. Nevermind that idea.
(it would work with a proxy though :P)
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest