Rotate an element

Hello, this code always jump the player when it touches the ground. I would like to do that for every jump you rotate 180 degrees, how can I do?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour {

	public bool IsAlive;
	public bool IsGrounded;

	public float JumpForce;

	private Rigidbody Body;
	private Vector3 DeathPosition;
	private Vector3 RespawnPosition;

	void awake() {
		RespawnPosition = transform.position;

	void Start () {
		IsAlive = true;
		JumpForce = 400f;
		DeathPosition = new Vector3 (-11f, 0f, 0f);
		IsGrounded = false;

		Body = gameObject.AddComponent<Rigidbody> ();
		Body.freezeRotation = true;

	void Update () {

	void OnCollisionEnter(Collision collision) {
		if (collision.gameObject.tag != "Death") {
			Body.AddForce (0f, JumpForce, 0f);
			IsGrounded = true;

		if (collision.gameObject.tag == "Death") {
			IsAlive = false;
			transform.position = DeathPosition;

	void OnCollisionExit(Collision collision) {
		IsGrounded = false;

You could give your class a target rotation variable:

private Quaternion targetRotation = Quaternion.identity;
private float rotationSpeed = 1f;

and then let your body rotate towards that target in the update loop:

void Update() {
    var rotation = Quaternion.RotateTowards(
        Time.deltaTime * rotationSpeed

    rigidbody.MoveRotation(transform.rotation * rotation);

when you jump, you can rotate the targetRotation by 180 degrees like this:

targetRotation.x += 180f;

(not sure if x is the right axis in your case)

error CS0019: Operator +' cannot be applied to operands of type UnityEngine.Quaternion’ and `UnityEngine.Quaternion’

use this

public float speed=1;
float countTime=0;
void Update(){
    if(countTime<=180 && !isGrounded){