# Collision Polygon and physics results in awkward movement

Get help using Construct 2

### » 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
17
S
8
G
5
Posts: 49
Reputation: 3,975

### » Tue Jul 11, 2017 6:06 am

@Ajbael The same thing has happened to me aswel!
B
41
S
21
G
12
Posts: 341
Reputation: 10,789

### » 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: 254
Reputation: 2,332

### » 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
17
S
8
G
5
Posts: 49
Reputation: 3,975

### » 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
141
S
31
G
88
Posts: 5,744
Reputation: 61,501

### » 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
17
S
8
G
5
Posts: 49
Reputation: 3,975

### » Wed Jul 12, 2017 2:13 pm

Well, strip it to the bare bones, and share the .capx.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Wed Jul 12, 2017 10:29 pm

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

B
17
S
8
G
5
Posts: 49
Reputation: 3,975

### » 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.

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
29
Posts: 2,493
Reputation: 21,450

### » 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.

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
17
S
8
G
5
Posts: 49
Reputation: 3,975

Next