Question by
AxelBlazeZX · May 14, 2017 at 07:16 PM ·
error2d gameshootingrespawn
Player Respawn Problem, Bullets dont move! [C#]
Hi I have aproblem! Everytime my player respawns and tries to shoot, the bullets dont move, they appear in position 0, 0, 0. What im doing wrong? Also Sorry for the bad english. Here’s the code im using:
public class MoveTrail : MonoBehaviour
{
public float maxSpeed = 40f;
PlatformerCharacter2D platformerCharacter2D;
Vector3 pos;
Vector3 velocity;
float nextTimeToSearch = 0;
//---------------------------------------------------------------------------------------------------
void Awake()
{
platformerCharacter2D = GameObject.Find("Player").GetComponent<PlatformerCharacter2D>();
velocity = new Vector3(maxSpeed * Time.deltaTime, 0, 0);
pos = transform.position;
}
//---------------------------------------------------------------------------------------------------
void Start()
{
if (platformerCharacter2D.m_FacingRight == true)
{
velocity = new Vector3(maxSpeed * 1 * Time.deltaTime, 0, 0);
}
else
{
velocity = new Vector3(maxSpeed * -1 * Time.deltaTime, 0, 0);
}
}
//---------------------------------------------------------------------------------------------------
void Update()
{
pos += velocity;
transform.position = pos;
Destroy(gameObject, 1);
}
}
Comment
Your answer
Follow this Question
Related Questions
Shooting bullets in mouse direction for 2D game 1 Answer
How do i make an ai shoot at player? 2D 0 Answers
2d shooting,Shooting bullets 2d 0 Answers
2d Shooting to Mouse position 0 Answers
how do i refer to the animation in the shooting script? 2 Answers