Controls Not Working - Argon Assault

The video: https://youtu.be/Tm_UiPcSkao
Hey guys! I am currently working on a game from the Unity 3D Course and unfortunately I can’t find the solution for the problem I’ve encountered (for more info watch the video). Even though the animation works fine, when I add the Movement Script, my game just does some weird things and controls aren’t working as they are supposed to do. Any help would be appreciated and thanks in advance!

Hi lakisha,

Welcome to our community! :slight_smile:

And thanks for sharing the video. That’s really helpful. I assume that the clamp values for the position might be causing the issue. Try to comment that part in your code out and assign the unclamped values to the position. Then test your game again. If the spaceship stops teleporting around, you found the issue.

Thanks a lot Nina, now it works :smile:
Is there any other way for me to restrict the ship from moving out of the camera view other than Mathf.Clamp? Maybe some invisible walls that are following player throughout the timeline or changing Mathf.Clamp part of the code to something else?

Mathf.Clamp is fine. The idea was to figure out if the clamping caused the issue. Now we know that it did, so we don’t have to look around for issues elsewhere anymore. :slight_smile:

Do the following: Move your ship to the edges of the screen while the game is not running. Note the respective values. Those are the values that you need for the clamping. Assign them to the exposed “clamp” fields in the Inspector. Then test your game again with Mathf.Clamp.

If it still does not work, compare your code to the Lecture Project Changes which can be found in the Resources of this lecture. Maybe there is something missing or wrong.

Oh I’ve realized that I switched min and max position in Mathf.Clamp so that was probably the issue. Now it works flawlessly! Once again, thank you so much for saving me from the stress of trying to figure out where I made a mistake, I really appreciate it :blush:

You’re welcome. :slight_smile:

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

Privacy & Terms