(Debug help) Player MOVE and SHOOT don't work

Hi,

if anyone can help me, I broke something and I can’t find the problem.

Everything seemed to be working until lesson 46.

But I just realised my player unit’s MOVE and SHOOT action stopped working. AI units are taking their turn perfectly (moving and shooting).

I’ve removed all Walls, to see if the grid was still workinsg, but the problem is still there. Player’s unit can’t move or shoot (only one can spin) / AI units are taking their turn properly.

I thought it might be related to converting the actions to generics (lessons 43), but I compared the scripts and didn’t find the difference.

If it is of any help, I realised this problem when my pathfinding Testing draw line stopped showing (somewhere adding the obstacles). So I have a problem with that too…

Any help would be appreciated, Thank you!

Can you select the Player Units? Can you select the Move Action? Do you see the Grid Visuals?
Enable the Debug Visuals for the Pathfinding, what do they look like?
Perhaps you didn’t set the correct LayerMask for detecting the obstacles? Make sure you only test the Obstacles layer, do not include Default otherwise it will hit the floor object and consider every position to be unwalkable.

If it’s not related to Pathfinding then add some logs throughout the action code to see where your code is stopping.

1 Like

Hi, thank you for your reply. I really enjoy your lessons!

I can select the player units.

I can select every actions.

The gridObject updates when changing actions. I see walkable tiles around, shoot range, or blue square under the player for spin action.

When I hit “T” on the keyboard to calculate path, I see an error : H cost is 0 and F and H are insanely high (see screen shot). [aftermath comment : finally no error here]

I have obstacles layer. I’m quite sure I’m using it since enemy units seems to move and shot properly.

I hope any of this info can help. I’m learning programming at school but this class uses more advanced techniques, it’s harder for me to debug.

image

Based on the grid visual it looks like everything is working, the only unwalkable positions are the ones with objects on them which is correct. You’re saying it doesn’t move if you click on any of those positions?

Maybe the issue is with the input, go to the UnitActionSystem and add a Debug.Log to verify that you are capturing clicks and calculating the grid position to take the action.

I had the exact same problem @francois_roy after this lesson. After a lot of double checking that my code was correct and quite a few debug messages I found the solution. It wasn’t the code at all! When I made the level I removed the mesh collider on the plane by mistake.

Just add a mesh collider to the “Plane” GameObject and everything will work again.

3 Likes

OMG! Thank you so much @Denatus!

I’ve spent so much time (hours) looking at the code, comparing with the repos, checking if I had misplaced scripts on some objects… I had gave up and temporarely stopped working on the project.

I would never have looked there, you literally allowed me to continue!

Thank you again!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms