Hy im a little developer(age 13) and i have a problem wile copying a script in youtube unity tutorials the wepons keeps fireing in the left. i tried to turning the spawn point
and it didn’t help. Here my script:
var Bullet : Transform;
var Spawn : Transform;
var BulletSpeed = 100;
(java)
function Update ()
{
if(Input.GetButtonDown("Fire1")){
Fire();
}
}
function Fire()
{
var Bullit = Instantiate(Bullet,Spawn.position,Spawn.rotation);
Bullit.rigidbody.AddForce(transform.forward * BulletSpeed);
}
In saw that if we add the “*BulletSpeed);” part it shoots in the left but if i don’t put it,it shoots straight but false down directly.
Try to use the 5th button to format your code or your can highlight them then press Ctrl+K. Try: bullet.rigidbody.AddForce(bullet.forward* bulletSpeed); It is possible that the gameObject you attached this script to is facing left, so when you add force using the gameObject orientation, it will always fly left from your view.
– Chronos-LIf you don't need the bullet to be affected by gravitation, you can set it's RigidBody-component's isKinematic to 'true'.
– incorrect