- Home /
Question by
Merljn · Apr 07, 2017 at 02:56 PM ·
directionmovemove an object
projectile move still the same direction
the Gun Need to be changed 45 - 80 so the handling of the pad is much better but the bullet come still in the same direction out i try mani Things but i cant find out what i Need to change exactly m just 3 weeks in Unity Need some Help
Thanks
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Shooter : MonoBehaviour {
public Transform crosshair;
public GameObject projectille;
private SteamVR_TrackedController controller;
// Use this for initialization
void Start () {
controller = GetComponent<SteamVR_TrackedController>();
controller.TriggerClicked += Shoot;
}
void Shoot(object sender, ClickedEventArgs e) {
if (projectille) {
GameObject newProjectille = Instantiate (projectille, crosshair.gameObject.transform.position, transform.rotation)as GameObject;
newProjectille.GetComponent<Rigidbody>().AddForce(transform.forward * 20f, ForceMode.VelocityChange);
}
}
}
Comment