Collision Polygon and physics results in awkward movement

Get help using Construct 2

Post » Tue Jul 11, 2017 3:37 am

Whenever I try using both a collision polygon and physics behavior, the object always ends up moving at a weird angle, even if the polygon is perfectly symmetrical. Why is this?

I have, for a long time, been interested in setting up custom physics instead of using the preset behavior, but I've been having a lot of issues figuring out the math for it.

EDIT: I've also noticed that any time I give a physics object a collision polygon that it not only moves at a weird angle, but faster than it is supposed to, if that helps anyone figure out what is going on.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Tue Jul 11, 2017 6:06 am

@Ajbael The same thing has happened to me aswel!
Image
B
24
S
13
G
11
Posts: 278
Reputation: 8,687

Post » Tue Jul 11, 2017 11:54 am

The 'faster than its supposed to' thing is because of the density - which is judged by the area of the collision polygon. By reducing the area of the polygon from the bounding box, you decrease the perceived 'mass' of the object.

Unfortunately, I can't explain why you're getting asymmetrical movement problems - it's not something I've come across myself :(
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Tue Jul 11, 2017 9:15 pm

mrtumbles wrote:The 'faster than its supposed to' thing is because of the density - which is judged by the area of the collision polygon. By reducing the area of the polygon from the bounding box, you decrease the perceived 'mass' of the object.

Unfortunately, I can't explain why you're getting asymmetrical movement problems - it's not something I've come across myself :(


Good to know about mass calculations, I thought it was based on the size of the sprite. As far as movement is concerned, would you be able to upload an example of a controllable sprite that has both physics and is also using a collision polygon? Something as simple as a sprite that rotates toward the position of the mouse and accelerates while "W" is held would be a big help to me.

I've tried simplifying everything down to the bare bones to try to figure out where the asymmetrical movement is coming from, but I haven't found any leads.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Wed Jul 12, 2017 7:29 am

Wouldn't it be easier for you to provide your .capx so we can see exactly what problems you have and hopefully offer clearer assistance?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,386
Reputation: 58,454

Post » Wed Jul 12, 2017 8:16 am

zenox98 wrote:Wouldn't it be easier for you to provide your .capx so we can see exactly what problems you have and hopefully offer clearer assistance?


There's not much to provide, I have the problem even when I strip it down to the bare bones.
The player sprite has the physics behavior and uses the collision polygon. The player sprite rotates toward the position of the cursor, and force is applied to the player sprite in the direction it is facing when "W" is held. The result is that the player sprite will fly crooked/drift when facing in most direction unless I used the bounding box or circle.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Wed Jul 12, 2017 2:13 pm

Well, strip it to the bare bones, and share the .capx.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jul 12, 2017 10:29 pm

99Instances2Go wrote:Well, strip it to the bare bones, and share the .capx.


https://drive.google.com/open?id=0B9tqO ... mVheVpWUDA
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Wed Jul 12, 2017 11:21 pm

I do not see a collisions setup in that capx. So i do not understand the initial question, still.

About this capx.

Besides a few weird things that you do, i see nothing wrong, or i miss something.

Weird things ? ....
1 In the physics world there is no such thing as an immediately movement, like you rotate that sprite. That will mess things up, got to do things smoothly. (with respect to time).
2 You compare to mouse coordinates that are not on the layer that you are moving, due the parallax. Run it in debug, en click 'mouse', watch the coordinates for the layers, you will understand.

So, if i do those things in a better way .....
https://www.dropbox.com/s/4sqbnd0bjioqe ... .capx?dl=0

..... Do we still have problems ? Do i miss something ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jul 12, 2017 11:51 pm

99Instances2Go wrote:I do not see a collisions setup in that capx. So i do not understand the initial question, still.

About this capx.

Besides a few weird things that you do, i see nothing wrong, or i miss something.

Weird things ? ....
1 In the physics world there is no such thing as an immediately movement, like you rotate that sprite. That will mess things up, got to do things smoothly. (with respect to time).
2 You compare to mouse coordinates that are not on the layer that you are moving, due the parallax. Run it in debug, en click 'mouse', watch the coordinates for the layers, you will understand.

So, if i do those things in a better way .....
https://www.dropbox.com/s/4sqbnd0bjioqe ... .capx?dl=0

..... Do we still have problems ? Do i miss something ?


There is no collision setup because I'm not having a collision issue. The issue is that whenever I use a Collision Polygon for a Physics object, that object will drift or move at a weird angle while moving.

It seems like the capx you provided with mouse coordinates relating to the layer the ship is on and replacing immediate turning with velocity based turning did smooth things out a bit, but the issue remains.

It is most noticeable when trying to follow a straight path while going up or down, the player object will drift along the side of the path you're trying to follow.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests