How do I prevent units from moving through solid walls?

Get help using Construct 2

Post » Fri Nov 13, 2015 11:02 pm

I am using the built in pathfinding for my Turn Based tactical game.

Here is my capx

https://www.dropbox.com/s/3iqjnrt6csg14lj/RebelStarShared.capx?dl=0

The units move along the path but they cut corners.

The tile map is 32x32 I have set the cellsize of the pathfinding to 16 or 32, and everything else I could think of, yet they units still cut corners straight through the "solid" walls. I have also tried other settings like disabling diagonal movement, however no improvement.

Image

I don't quite understand why there is this problem and why it cannot be set to obey the solid walls. I know there is another pathfinding plugin but first glance it looks more complicated to use so I was hoping to see if I could acceptable results from what I have built already.

The game is a work in progress and I have no commercial aspirations for it, simply a hobby project. However, please do not use my code for yourself without talking to me first. Thanks.
B
37
S
9
G
5
Posts: 437
Reputation: 6,094

Post » Sat Nov 14, 2015 5:32 am

Hey man,

An easy way to do it would be to give your player the 8 direction behavior and set rotation and standard controls to none.

It seems to work after that.
B
18
S
2
Posts: 48
Reputation: 896

Post » Sat Nov 14, 2015 5:33 am

Since your player has no "collision detection for solids" Giving it an 8 direction will

Also, I would work on the detection box and maybe enlarging the size of the doorways so you have a smoother path finding animation
B
18
S
2
Posts: 48
Reputation: 896

Post » Sat Nov 14, 2015 5:42 am

HI @ryrydawg I am not sure I follow. The 8 direction behaviour would be a possibility for the player but I am not sure how that would solve the issue for the CPU player.
B
37
S
9
G
5
Posts: 437
Reputation: 6,094

Post » Sat Nov 14, 2015 7:07 am

czar wrote:HI @ryrydawg I am not sure I follow. The 8 direction behaviour would be a possibility for the player but I am not sure how that would solve the issue for the CPU player.


I have uploaded the new version

Changes :

- Made the player and CPU player smaller to avoid the collision box catching on corners
- Set the cpu player and human player to 8 direction so that they have a collision with solid objects property.

Note that the size of the cpu and player sprites were changed only on the layer. Not the actual sprite. You can play around with the sizes to get the perfect fit.

As I said before, there are probably other ways to solve your problem but the would be the quickest

https://onedrive.live.com/redir?resid=E ... ile%2ccapx

You could also just scrap everything I just said and simply add a solid behavior to the player and CPU player. That seems to work too but the movement looks too fake
B
18
S
2
Posts: 48
Reputation: 896

Post » Sat Nov 14, 2015 9:27 am

Nice result @ryrydawg. That look much more acceptable. Sometimes the player gets caught in certain spots but I may be able to work that out. I will need to check it closer in the morning.

R
B
37
S
9
G
5
Posts: 437
Reputation: 6,094

Post » Sat Nov 14, 2015 11:32 am

@czar

Awesome! If you figure it out, please post it here :)

Keep well
B
18
S
2
Posts: 48
Reputation: 896


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 21 guests