Hi I’m having a problem with a projectile for my First Person Character Controller, when I press the fire button it spawns but it is rotated facing a different direction instead of straight forward, does anyone know what is wrong?
Here’s a Video of my problem.
Here’s my code.
var projectile : Rigidbody;
var speed = 10;
function Update()
{
if( Input.GetButtonDown( “Fire1” ) )
{
audio.Play();
// Delay a clip by 1 sec (44100 samples)
audio.Play(44100);
var instantiatedProjectile : Rigidbody = Instantiate(
projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider,
transform.root.collider );
}
}
The rotation of the Bullet is Rotation X0 Y90 Z0
Y was originally 0 but I changed it, it still no improvement.
Also could the problem be this? transform.rotation );
Can anyone help me?
Fixed the problem, using different model.
Tried the video but it says it's private
– FTheCloudDryden Richardson, when you have a problem like this is better to put your script instead of a video, unless the problem is in physics or something like that.
– Uriel_96Like Uriel Said perhaps if you where to post the code where you create the projectile we would be able to help you a bit more. It sounds like you might have a problem in you Instantiate call though, obviously I'm not sure how your handling the projectiles but I found it works best if you make a prefab and instantiate it with the players rotation. You may also want to check the axises of the projectile to see if perhaps it is instantiating the proper way but you should be using the x instead of z or vice versa. Hope that helps a little bit. If you post your code I'll be more help.
– HHamelineWe cannot help you if we don't see the code.
– anon73820239