Need help with a Zombie game

ok i have been working on a game for 3 days now but i stumbled upon a problems im trying to ad Aiming Down sights But when i do It the gun goes way Left And im Also trying to add Raycast Shooting And sounds but i cant figure it out and when i do find tutorials they either really good but there only 1 episode or they dont explain good enough can anyone help with scripting these.

Hi wm9prod

You probably would want to download some example projects and try to use them as a base to your game. Modifying already working scripts is probably one of the easiest ways to get your hands dirty as a beginner :slight_smile:

Camera movement:
Depending whether your game is fps or 3rd person shooter, the camera will be controlled slightly different. You can find great simple scripts from examples.

Raycast shooting:
You can determine which object your mouse cliked on by

var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
    Debug.Log (hit.collider.gameObject.name); // prints out the name of hit object
}

Sounds:
You have to attach AudioSource to your gameobject and clip of the shooting sound to your audiosource.
After that it’s as simple as:

audio.Play();

thanks but do you know any ADS code all the ones i use put the gun like 5 feet above me

Make sure you only have your centering program on the camera and that the gun is not a child of the camera… if it is make a new game object(located in the same transform position and rotation as the camera) and place the scripts that were on the camera (minus the centering script) onto this one, then the centering script onto the camera.

(I’m only guessing that that could work)