- Home /
Question by
oeuvre · Apr 12, 2014 at 05:41 AM ·
first person controller
Rotating a child weapon of First Person Controller
Hey, so I'm trying to create a weapon that is a child of the First Person Controller. This script works well, but I want the mace to face straight ahead instead of sideways. It fires straight ahead but the object itself is not rotating correctly. I tried changing transform.rotation to Quaternion.identity and Quaternion.Euler but then it spits out in random directions. Help is much appreciated, thanks! I included a screenshot to help too.
using UnityEngine;
using System.Collections;
public class WeaponUsage : MonoBehaviour {
public float lifetime = 2.25f;
public GameObject maceweapon;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0)) {
GameObject go;
go = Instantiate(maceweapon, transform.position, transform.rotation) as GameObject;
Destroy(go,lifetime);
go.transform.parent=transform;
}
}
}
Comment