Hi there. I am having some issues and have been looking through all the different answers/questions on the site, but haven’t really found anything that hits the nail on the head for my problem.
I am pretty new to Unity and games programming (I know how to code, just not 3D games!). I was wanting to make my own custom movement script. I wanted to make a movement script where the L and R keys rotated the character left and right, the U key moves forward and D key moves backwards, with space for jump. I was also looking for the mouse look to only work when I hold down the right mouse key.
I had been looking at all kinds of examples, but what I notice is, using the standard assets FPSController, when I try to make my own scripts it is essentially overwritten by the generated scripts. When I disable them (the generated scripts), mines don’t do anything. What do I need to do in order to allow the character to move using only my script? Must it have a motor attached to it?
If anyone can help me with the scripts and attaching them properly, I would be very grateful. I know the information is out there, but there is so much information it is a little overwhelming, a little help in narrowing it down would be appreciated.
Hi mate, thanks for getting back. Apologies for the follow up answer instead of comment. I will have a jump feature in, I was just focusing on ground movement at the moment. I shall implement the changes and get back, thanks!
– rross46Just to clarify a few things, the ground() method was brought in because when I tried to have a constant gravity effect, the forward/backward movement was also being called, I don't know if my solution is the best, but it manages to work. In my jump code I set the movement vectors to 0, this is because the jump was not only jumping, but moving in the direction it is facing also, I just wanted it to jump when the jump key is pressed.
– rross46The code is fine as long as you are happy with it. A minor nit: by convention function and class names start with capital letters so your function should be Ground(). The compiler won't complain, but folks on this list who read your code will have to work harder. If this question is answered, you can you click the checkmark next to the answer to close it out.
– robertbuOops my bad, forgot to put caps on it. Could anyone offer any suggestions for making it so that it doesn't glide if I jump then press up or down?
– rross46Also, I was wondering how to jump whilst moving as well. Right now it just sort of blips. Having trouble figuring it out. Any help would be appreciated.
– rross46