my biggest problem is :
I am making a commercial FPS Game and i am stuck on MuzzlePoint’s Rotation.
i want my Bullet Tracer go from the muzzlePoint’s current location to center of the screen (crosshair’s center).
my Incomplete Script:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AssaultRifle : MonoBehaviour {
public float currentBullets;
public float bulletsPerMag;
public float fireRate;
public GameObject muzzlePoint;
public Camera FPSCamera;
float firetimer;
bool isReloading;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.Mouse0) && currentBullets < 0) {
Fire ();
}
}
void Fire()
{
if (isReloading)
return;
RaycastHit hit;
if (Physics.Raycast (FPSCamera.transform.position, FPSCamera.transform.forward)) {
// What to do here ????
// muzzlePoint.transform.localRotation = hit.point; Failed!!! :(
}
if (firetimer < fireRate)
firetimer = Time.deltaTime;
}
}
all i want to do is keep the rotation of MuzzlePoint to the raycasthit hit’s hit Location…
plzz helpp !!!