I’m Currently been working on a simple, beat em up style game, inspired by games like Castle Crashers, Scott Pilgrim the Game and the old D&D Capcom Brawlers. I currently have been learning Unity and although I’ve figured out how to use most of the features i still have a hard time understanding scripting, my brain just refuses to learn it for some reason, guess it douse not help i suck at Math.
public class PlayerControllerScript : MonoBehaviour
{
public float maxSpeed = 6f;
bool facingRight = true;
Animator anim;
void Start ()
{
anim = GetComponent<Animator> ();
}
void FixedUpdate ()
{
float move = Input.GetAxisRaw ("Horizontal");
anim.SetFloat ("Speed", Mathf.Abs (move));
GetComponent<Rigidbody2D>().velocity = new Vector2 (move * maxSpeed, GetComponent<Rigidbody2D>().velocity.y);
if (move > 0 && !facingRight)
Flip ();
else if (move < 0 && facingRight)
Flip ();
}
void Flip()
{
facingRight = !facingRight;
Vector3 TheScale = transform.localScale;
TheScale.x *= -1;
transform.localScale = TheScale;
}
}
This is currently the code I Frankensteined together by watching tutorials, i can move left and right and the animation changes to from walking to running with some blend tree, only thing i dont under stand is how id go about adding a Vertical axis to give the game 3D movement. ive tried a few things but the leave the script useless and Im unsure of how to apply it to my script.
if anyone has any ideas or a script that works better and is easier to edit id greatly appreciate it again im mad basic at this scripting thing so i apologize if im doing things wrong.