I am trying to get it so that if the player collides with the rope then they connect with each other and swing at the same time. I have tried to make the player a parent of the rope and turn off gravity but that doesnt work, as it rotates the player and he does not follow the movement of the rope. Am I doing this the wrong way?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RopeAttach : MonoBehaviour
{
public GameObject player;
public Rigidbody Rb;
void Start()
{
Rb = GameObject.Find("player").GetComponent<Rigidbody>();
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject == player)
{
player.transform.parent = transform;
Rb.useGravity = false;
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject == player)
{
player.transform.parent = null;
Rb.useGravity = true;
}
}
}