Answer the question
In order to leave comments, you need to log in
How to add flip 2d function?
How to add flip d 2d function?
Can't add flip function! Help me please!
using UnityEngine;
using System.Collections;
public class Control : MonoBehavior {
public float speed = 10f;
public bool Grounded = false;
public Transform GroundCheck;
public float GroundRadius = 0.2f;
public LayerMask wtfIsGround;
Rigidbody2D rig;
void Start() {
rig = GetComponent();
}
void Update () {
Grounded = Physics2D.OverlapCircle(GroundCheck.position, GroundRadius, wtfIsGround);
if (Input.GetKeyDown(KeyCode.Space) && Grounded) {
rig.AddForce(new Vector2(0, 800f));
}
float move;
move = Input.GetAxis("horizontal");
rig.velocity = new Vector2(move * speed, rig.velocity.y);
}
}
Answer the question
In order to leave comments, you need to log in
Hello! To do this, write the following lines of code)
void Flip()
{
if(Input.GetAxis("Horizontal") < 0)
{
transform.localRotation = Quaternion.Euler(0, 180, 0);
}
if (Input.GetAxis("Horizontal") > 0)
{
transform.localRotation = Quaternion.Euler(0, 0, 0);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question