Help with movement

Hi all,

I’m just learning to script and have been trolling everything I can on learning (thanks tonyd for the long post. very helpful) and will continuously be reading and re-reading, looking over existing posted script, etc. But I’d like to start doing something useful to keep the enthusiasm going. I’ve made a list of the various aspects of the game I have in mind that need coding and want to start with the movement. I’ve tossed in the character controller provided and found other scripts for similar and probably more advanced movement but I’d like to do/add the following:

Add various movement types such as crouch and crawl and have the speed of movement slowed accordingly.
Add middle mouse click to cause the FPS to move back to 3rd person and the distance adjusted via mouse wheel (similar to Fallout 3 or Oblivion).

I’ve been poking around looking for what the call is for middleMouse (<–is that it?) and the correct way to do that. I can figure out things such as the camera needs to be ‘grabbed’ for this and it’s position moved (-) relative to the character, but I don’t know the proper way to code that yet =/ Or where to place that in the existing movement code.

Any and all suggestions most welcome and appreciated!

Hi, welcome to the forum!

The middle mouse button is button 2 and you can get its status using the Input.GetMouseButtonXXX functions (eg, GetMouseButton checks whether the button is currently held down).

As for the camera, are you looking for a camera that orbits the player when the mouse is moved? You might find the Mouse Orbit camera script useful as a starting point - it is supplied with Unity’s standard assets.

Thanks!! I’ll look at Mouse Orbit Camera and see if I can tie it into the main script in conjunction with the GetMousebutton function =)