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. Code (CSharp): 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
Rotate the character sprite. Look up how to rotate a sprite. You will probably rotate the Z on the Transform.Rotation.
i dont want rotate instantly i want when player press jump character start rotating to when hit ground
Look up a Lerp function, it will slowly change between the 2 values. transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, 0, targetAngle), rotationSpeed * Time.deltaTime);