I have a moving object which will propelled a projectile from it when you press shift key
I want my projectile move to specific point (0,0,10)
I have tried the following code but it doesn’t work
if (Input.GetKey("right shift")||Input.GetKey("left shift")) {
Rigidbody clone;
clone = Instantiate(projectile1, transform.position, transform.rotation) as Rigidbody;
clone.velocity=new Vector3(0,0,10);
any one can help?
If you want a constant velocity, use MoveTowards instead: MoveTowards(pointA, pointB, delta) returns a point in the line pointA-pointB distant delta units from pointA – and clamped to pointB, thus it never goes beyond the destination point.
where speed is in meters (or units) per second.