So what i have in this 2.5d game is a simple movement and jump script and i would like to try and implement a melee script that can attack both left and right smoothly and make it so that it does damage but i don’t know where to start.
This is my script:
public Transform playertrn;
public Rigidbody playerRB;
public int speed;
private bool isFalling = false;
private bool doubleJump = false;
public Vector3 JumpHeight = new Vector3 (0, 8, 0);
void Start ()
{
playertrn = GetComponent<Transform> ();
playerRB = GetComponent<Rigidbody> ();
Physics.gravity = new Vector3(0, -11.0F, 0);
}
void Update ()
{
if (Input.GetKey (KeyCode.D))
{
playertrn.Translate (new Vector3(speed, 0, 0) * speed * Time.deltaTime);
}
if (Input.GetKey (KeyCode.A))
{
playertrn.Translate (new Vector3 (-speed, 0, 0) * speed * Time.deltaTime);
}
if (Input.GetKey (KeyCode.Space) && !isFalling)
{
playerRB.velocity = JumpHeight;
isFalling = true;
}
}
void OnCollisionStay ()
{
isFalling = false;
}
}
would i be able to get some advice on where to start with the melee system please
Thanks in advance