solid object - bug

Discussion and feedback on Construct 2

Post » Mon Feb 23, 2015 8:07 pm

Hi All,

I have been having na intermittently problem involving platform objects and solids on construct 2, it´s more likely to happen if the layout has just loaded.

I have a platform object that goes to the left or right when the user touches the screen. I also have to solid objects that should stop this object from moving.

The problem is that sometimes the platform object goes through the solid object.

Do you guys have any idea what could be happening.

I have already tried the invisible square behind the sprite and it didn't work.

Kind Regards,

Allan Lopes
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 4
Reputation: 183

Post » Tue Feb 24, 2015 4:11 am

Hello Allan,

This is probably happening because the Platform Object moves too fast and some times, between two ticks, it travels more than the width of the solid objects, so it never collides and it looks like it passes trough.

This is most likely to happen on Firefox, because it has some terrible performance spikes lately, that seems to affect collision detection (among other things). Try previewing the layout in Chrome or NW.js, I believe that you'll get different, more as expected, results there.

You could also try to slow down the platform speed a bit, or use the clamp expression to limit the Sprite's position on the X axis. The event for doing this should look like this:

System|Every tick-----> s1 | Set X to clamp(self.X, "lowX", "highX")

where "lowX" and "highX" should be the number values that define the furthest to the left/right that you want your Sprite to be able to move.
composer - multimedia artist
www.eli0s.com/en/
B
67
S
26
G
4
Posts: 1,145
Reputation: 9,622

Post » Tue Feb 24, 2015 7:43 am

The answer is logical.

Assuming 60FPS, if an object is set to 50000 px per second (which is ridiculous), then in one tick, the object can travel 50000/60 px per tick ( approx 833).

Considering the object that it's meant to collide with is only 20px wide, it's pretty obvious that the chances of a collision are slim, as the speeding object will easily pass by the collision object.

To put it another way: if you had a standard screen size of say 1024x768, then you have set an object to travel at roughly 50 times the screen width every second. I can't envisage there ever being a need for such a thing - it makes no sense.

The answer is to reduce the speed, or increase the collision object, but at the speed you are currently using, I can't see that increasing the collision object being of much use.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
77
Posts: 5,188
Reputation: 54,281

Post » Tue Feb 24, 2015 4:37 pm

Thankys eli0s and zenox98! I will try another way.
B
3
Posts: 4
Reputation: 183

Post » Tue Feb 24, 2015 5:47 pm

@allanblopes , what is it that you are trying to do? What do you want to make? Perhaps there is a simple way to achieve it, if you tell us what you're after maybe we can help with a practical example.
composer - multimedia artist
www.eli0s.com/en/
B
67
S
26
G
4
Posts: 1,145
Reputation: 9,622


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests