Here I took a picture to help you understand more of what I want!: Imgur: The magic of the Internet
so the red dot down in the entrance area, is where my mouse cursor was and the second dot above the entrance is where it was shooting, I would like the bullets to shoot where the mouse cursor is and if possible have the gun Move with the cursor on the Y axis (up and down)… also instead of having a cursor is there a way I could use a crosshair “image” that I make instead…
Here is the mouse code
// Turn the player to face the mouse cursor.
Turning ();
void Turning ()
{
//Create a ray from the mouse cursor on screen in the direction of the camera.
Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
// Create a RaycastHit variable to store information about what was hit by the ray.
RaycastHit floorHit;
// Perform the raycast and if it hits something on the floor layer...
if(Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
{
// Create a vector from the player to the point on the floor the raycast from the mouse hit.
Vector3 playerToMouse = floorHit.point - transform.position;
// Ensure the vector is entirely along the floor plane.
playerToMouse.y = 0f;
// Create a quaternion (rotation) based on looking down the vector from the player to the mouse.
Quaternion newRotatation = Quaternion.LookRotation (playerToMouse);
// Set the player's rotation to this new rotation.
playerRigidbody.MoveRotation (newRotatation);
}
I think that’s about it these are all the things I am having trouble with and can’t figure out i’m a noob thanks in advance for any help!