I am making a stickman game that’s based on physics completely, like Dani’s Off The Sticks. I have the balance script, movement and grabbing ready and working, but I want to make the enemy stickman completely lose balance when hit. How do I make that?
Stickman npc balance script:
Code (CSharp):
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- public class Balance : MonoBehaviour
- {
- public float restingAngle = 0f;
- public float force = 750f;
-
- private Rigidbody2D rb;
-
- private void Start()
- {
- rb = GetComponent();
- }
-
- private void FixedUpdate()
- {
- rb.MoveRotation(Mathf.LerpAngle(rb.rotation, restingAngle, force * Time.deltaTime));
- }
- }