How do I get accurate collisions with the MoveTo behavior?

Get help using Construct 2

Post » Mon Mar 06, 2017 9:44 pm

Below is the capx that will demonstrate my problem. It is very simple and only has one line of code but requires the MoveTo Behavior http://c2rexplugins.weebly.com/rex_moveto.html

Capx: https://www.dropbox.com/s/uymgjzilg8q3k ... .capx?dl=0

The problem: I want the player to be able to move to the mouse's coordinates whenever the left mouse button is held down. This works fine but when I have the player move to a solid wall without stopping they will slide really fast against it. For some reason this only happens when the player is moving against a wall on the left or top side.

If this doesn't make sense you have to try holding the mouse button on the very left side of the screen and when the player comes into contact with the wall they will slide up at great speed. Also, the reason I have the 8direction behavior is simply so the player interacts with solids. I have also tried rex's PushOutSolid behavior but it gives the same result.

I want the collisions to be like it is in most top down 2d games where the player will slide against the wall at a normal speed and not jitter or go too fast.
B
17
S
4
G
4
Posts: 59
Reputation: 3,121

Post » Mon Mar 06, 2017 10:12 pm

I don't use plugins for something as simple as direction and movement controls.

The plugin doesn't stop when it should and continues to try and go left and it does not address acceleration properly.

My suggestion is get rid of the plugin and use the 8 direct commands which adjust for acceleration.
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,800

Post » Mon Mar 06, 2017 11:44 pm

lamar wrote:I don't use plugins for something as simple as direction and movement controls.

The plugin doesn't stop when it should and continues to try and go left and it does not address acceleration properly.

My suggestion is get rid of the plugin and use the 8 direct commands which adjust for acceleration.


Ok, that makes sense but I would like full 360 movement so should I use the custom movement behavior? Or is there a better one to use for something like this?
B
17
S
4
G
4
Posts: 59
Reputation: 3,121

Post » Mon Mar 06, 2017 11:51 pm

Aleyba wrote:
lamar wrote:I don't use plugins for something as simple as direction and movement controls.

The plugin doesn't stop when it should and continues to try and go left and it does not address acceleration properly.

My suggestion is get rid of the plugin and use the 8 direct commands which adjust for acceleration.


Ok, that makes sense but I would like full 360 movement so should I use the custom movement behavior? Or is there a better one to use for something like this?


8 directions has a 360 in the settings if you are using a single sprite or you could use the car movement.

Custom movements are not as well defined by acceleration as 8 direction but can be used.
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,800

Post » Tue Mar 07, 2017 12:02 am

lamar wrote:
Aleyba wrote:
lamar wrote:I don't use plugins for something as simple as direction and movement controls.

The plugin doesn't stop when it should and continues to try and go left and it does not address acceleration properly.

My suggestion is get rid of the plugin and use the 8 direct commands which adjust for acceleration.


Ok, that makes sense but I would like full 360 movement so should I use the custom movement behavior? Or is there a better one to use for something like this?


8 directions has a 360 in the settings if you are using a single sprite or you could use the car movement.

Custom movements are not as well defined by acceleration as 8 direction but can be used.


I want the player to move without having their angle changed, doesn't the 8dir behavior force that?
B
17
S
4
G
4
Posts: 59
Reputation: 3,121

Post » Tue Mar 07, 2017 12:51 am

Aleyba wrote:
I want the player to move without having their angle changed, doesn't the 8dir behavior force that?


If you don't want the angle changed set 360 smooth to off in the 8 direction settings.

You can also set it to move in 4 directions or 2 directions.

It can be used either way.
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,800

Post » Tue Mar 07, 2017 2:47 am

lamar wrote:
Aleyba wrote:
I want the player to move without having their angle changed, doesn't the 8dir behavior force that?


If you don't want the angle changed set 360 smooth to off in the 8 direction settings.

You can also set it to move in 4 directions or 2 directions.

It can be used either way.


Thank you for your help. I ended up using the 8 Direction behavior like you said and took the angle from the player to the mouse to get the X and Y Vectors that I need to get the player moving.

Vector.X = cos(angle(Player.X,Player.Y,Mouse.X,Mouse.Y)-180)
Vector.Y = sin(angle(Player.X,Player.Y,Mouse.X,Mouse.Y)-180)

Works great :)
B
17
S
4
G
4
Posts: 59
Reputation: 3,121


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests