hi guys I making a game. in my game if u press space u go up or down (we have 2 ground) and I change gravity scale in rigidBody2D in player GameObject.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
private Rigidbody2D rigid;
// Start is called before the first frame update
void Start()
{
rigid = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
// if (Input.touchCount > 0)
// {
// Touch tch = Input.GetTouch(0);
//if (tch.phase == TouchPhase.Began)
if(Input.GetKeyDown(KeyCode.Space))
{
if (rigid.gravityScale == 3)
{
rigid.gravityScale = -3;
}
else
{
rigid.gravityScale = 3;
}
}
//}
}
}
now i need to rotate player GameObject 180 degree (before hit ground top or bottom)
please help