First person controller Prefab Question

Trying to make it so i can just use the First person controller prefab as a basic FPS controller to just get an idea of how my game will work. I just started this stuff a couple days ago and know barely any java script, but thanks to Tornado Twins got a good idea of what to do. I've got the script down and it shoots fine, I added the spawn point of the bullets in front of the player and dropped it in the Controller Prefab, now if i move the camera left or right, the spawn point does to and i can turn my gun, but if i try to look up or down the spawn point stays at the same height and doesnt rotate, any idea how to fix it? heres the parts i added to the FPSWalker script: (note i took out a lot of the script, just parts i manually put in)

if(Input.GetButtonDown("Fire1"))

{

var bullit = Instantiate(bullitPrefab, GameObject.Find("SpawnPointTwo").transform.position, Quaternion.identity); bullit.rigidbody.AddForce(transform.forward * 2000);

} if(Input.GetButtonDown("Fire2")) { var bullits = Instantiate(bulletPrefab, GameObject.Find("SpawnPointTwo").transform.position, Quaternion.identity); bullits.rigidbody.AddForce(transform.forward * 8000); }

I put this right after the jump button, outside of the if on ground part. (i also added the variables on top so thats fine too). I dont know if i should even attempt to attach this in the mouse move script and see if that fixes it or is that not the problem? please help if you can :)

Put the script on the camera that's a child of the controller instead of the controller itself, since the camera looks up and down but the controller doesn't (and, in fact, can't).

You use the FPS Walker as reference for your shooting direction. The capsule which represents your player is rotated horizontally by the mouse-look script attached to the Controller. YOu will find the main camera as a child of your First Person Controller. I would copy the above code and put it into a separate script. Putting this code into any FPS Walker or Mouse Look script will just make it very messy. Attach this new script to the Main camera and you should be all set. The main camera has another mouse look script attached which is responsible for the vertical rotation. That's why your current solution ignored the vertical rotation, because the FPS capsule doesn't care about any vertical rotation, it's the main camera which is repsonsible for this rotation.

Try this!

var BulletPrefab:Transform;
var force : float = 2000;

function Update()
{
if(Input.GetButtonDown(“Fire1”))
{
var bullet = Instantiate(BulletPrefab,

GameObject.Find(“spawnPoint”).transform.position,

GameObject.Find(“Gun”).transform.rotation);

bullet.rigidbody.AddForce(bullet.transform.forward * force);

}
}