I am using Free 2d Plateformer kit. I need help adjusting Muzzle position. Although the muzzle object is inside the player gameobject, and it only appears when the game is run. It disappears once the game has stopped.
I tried changing in script with no luck. Please help here’s the script.
/// <summary>
/// Fire
/// </summary>
public void Shoot()
{
// ... set the animator Shoot trigger parameter
an.SetTrigger ( "Shoot" );
audio.PlayOneShot ( currentWeapon.shotSound );
// If the player is facing right...
if( _Right )
{
// Create a bullet instance
Rigidbody2D bulletInstance = Instantiate ( currentWeapon.bullet, currentWeapon.muzzle.position, Quaternion.Euler ( new Vector3(0, 0, angle) ) ) as Rigidbody2D;
bulletInstance.velocity = new Vector2 ( lenX, lenY ).normalized * currentWeapon.speed;
if( GetComponent<PlayerView>() )
{
GetComponent<PlayerView>().Shoot ( new Vector2 ( lenX, lenY ).normalized, angle );
}
bulletInstance.transform.GetComponent<Bullet>().SetData ( currentWeapon.power, true );
}
else
{
// Create a bullet instance
Rigidbody2D bulletInstance = Instantiate ( currentWeapon.bullet, currentWeapon.muzzle.position, Quaternion.Euler ( new Vector3(0, 0, 180f-angle)) ) as Rigidbody2D;
bulletInstance.velocity = new Vector2 ( -lenX, lenY ).normalized * currentWeapon.speed;
if( GetComponent<PlayerView>() )
{
GetComponent<PlayerView>().Shoot ( new Vector2 ( -lenX, lenY ).normalized, 180f-angle );
}
bulletInstance.transform.GetComponent<Bullet>().SetData ( currentWeapon.power, true );
}