sprite collision test too early in C3

Get help using Construct 3!

Post » Sat Oct 14, 2017 6:43 pm

am implementing a ricochet example where if a bullet hits the shooter, the sprite dies or score decrements.
the problem is that bullets overlap the shooter initially so the collision condition is true immediately.
should collision tests be deferred until the bounding rectangle is cleared?

I moved the image points outside the bounding rectangle to fix the problem, but it doesn't look as good.
Any other suggested fixes?
thx
B
9
S
1
G
1
Posts: 9
Reputation: 943

Post » Sat Oct 14, 2017 9:46 pm

Give the bullet an instance variable, set to false. When you fire it, set the instance variable to true. On the collision event have a condition for if instance variable is true then take the damage. Basically you are checking that the bullet is in its rebound state when it hits the player.
B
48
S
19
G
87
Posts: 2,316
Reputation: 51,516

Post » Sat Oct 14, 2017 11:25 pm

you gave me the solution idea. thx.

however, couldn't the instance set on shooter firing mess up if bullet stays inside shooter rectangle for more than 1 tick?

since ricochet can only occur after hitting a barrier,
i'll set to false when shooting, but set to true when a bullet hits a barrier.
then if a bullet hits the shooter with instance false it must still be firing and can be ignored.
B
9
S
1
G
1
Posts: 9
Reputation: 943

Post » Sat Oct 14, 2017 11:47 pm

Yeah that sounds fine, I can't see your game so was just giving a general solution. It's up to you to decide when you want to toggle that variable and when it hits the barrier seems correct.
B
48
S
19
G
87
Posts: 2,316
Reputation: 51,516


Return to How do I...?

Who is online

Users browsing this forum: No registered users and 4 guests