- Home /
Instantiate object that points to the direction
I'm trying instantiate a object from other (a Cannon), and this Cannon have rotation and point for some angle. And when I press a button the "projectile" need go to the same direction that Cannon pointed!
I can rotate the object and instantiate it for the same rotation that Cannon, but I cannt make this object go to the same direction of the cannon point.
-
- little piece of CODE:
var vec_power_shot = Vector3.zero;
var speed_human = 300;
var power_shot = 7;
//When I press Fire
function HumanCannon()
{
vec_power_shot.x = speed_human;
vec_power_shot = transform.TransformDirection(vec_power_shot);
var instanceShot = Instantiate(objtPlayer,transform.position,transform.rotation);
instanceShot.rigidbody.AddRelativeForce(-vec_power_shot);
//negative because turn more correctly the direction, and because I think my Canon is with different directions
}
I hope you understand what I want, at least what I said. =]