Let a car bounce of boundaries

Get help using Construct 2

Post » Sat Dec 07, 2013 1:06 pm

Hello! I tried a few things with car and/or bullet behaviors but could not get it right, yet. Maybe some experienced users know how to fix it?

I have a player sprite (car) inside another big sprite which acts as boundary for the level. After a few experiments with settings and how to do it I managed to let it bounce off the wall with the bullet behavior and actions. But sometimes the player sprite gets stuck at the wall and is spinning around the whole time.

Here is the code for it so far:


Does anyone know how to fix this?
And is it possible to export a single layout instead of the whole project to post an example?

ps: when I let the sprite bounce off with bullet behavior and speed 0 I get an error popup in chrome:
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
55
S
16
G
6
Posts: 726
Reputation: 9,251

Post » Sat Dec 07, 2013 3:18 pm

The collision polygon is used to define the outside of a sprite, you are trying to bounce of the outside, but inwards, that is obviously a strange thing to do, bouncing into a solid object.

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Dec 07, 2013 4:43 pm

Right, but it seems to work in many cases. Only sometimes when Car+Bullet are combined on one sprite it gets "stuck" and swirls around. But other times it works like I want it and bounces back with the proper angle and speed. I will try to copy all elements in a new project to post a .capx.

/Update: Here is an example.
https://dl.dropboxusercontent.com/u/26714455/CarBullet_Bounce.capxBl4ckSh33p2013-12-07 16:49:08
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
55
S
16
G
6
Posts: 726
Reputation: 9,251

Post » Sat Dec 07, 2013 5:11 pm

What is the benefit of doing it in a different way than the intended one?

Why try to make it work this way when there is a perfectly good solution to do it that is not only easier, but also less prone to unwanted behaviour?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Dec 07, 2013 5:30 pm

I found another example in the forums where someone used this method and it worked for him. But I did not try it with several boundary sprites yet because it was easier to just draw the outlines in one sprite.

I will try if the swirly behavior is gone when I use separate sprites for each "wall" of the level and collision without overlapping.
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
55
S
16
G
6
Posts: 726
Reputation: 9,251

Post » Sat Dec 07, 2013 5:42 pm

I tried it with "normal" bouncing on contact and it seems to work fine from the left side. But if you go around and hit the wall from the right something strange happens. The sprite does not bounce off and is stuck at the wall. o.O

Example: https://dl.dropboxusercontent.com/u/26714455/CarBullet_Bounce2.capx
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
55
S
16
G
6
Posts: 726
Reputation: 9,251

Post » Thu Dec 19, 2013 8:06 pm

Any ideas why it is not bouncing of when it comes from the right side or below?
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
55
S
16
G
6
Posts: 726
Reputation: 9,251


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 29 guests