I’m trying to make make third person fight game. Where you can grapple and toss the enemy character.
So far here is my script and I want the character to throw the enemy rigidbody to a specific point every time I activate the script. I have been dabbling with variations of this script and This is what I have so far. So in full application, the main character will grab the enemies collar and throw him up and out. here is what I have so far :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.GraphicsBuffer;
public class addforce : MonoBehaviour
{
Rigidbody RB;
float magnitude = 500;
public Transform ThrowPt;
public GameObject ragdoller;
void Start()
{
if (Input.GetKeyDown(KeyCode.E))
{
RB = GetComponent<Rigidbody>();
RB.AddForce(Vector3.forward * magnitude, ForceMode.Impulse);
Debug.Log("Threw it");
ragdoller.SetActive(true);
}
if (Input.GetKeyUp(KeyCode.E))
{
ragdoller.SetActive(false);
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
RB = GetComponent<Rigidbody>();
RB.AddForce(Vector3.forward * magnitude, ForceMode.Impulse);
Debug.Log("Threw it");
ragdoller.SetActive(true);
}
if (Input.GetKeyUp(KeyCode.E))
{
ragdoller.SetActive(false);
}
}
}