Hi! Here is my code :
using System.Collections.Generic;
using UnityEngine;
public class Parachutist : MonoBehaviour
{
public Rigidbody parachutist;
public GameObject parachute;
private float distanceToOpenParachute = 24f;
private float dragAfterOpeningParachute = 3f;
private void FixedUpdate()
{
OpenParachuteCondition();
}
void OpenParachuteCondition()
{
Ray ray = new Ray(transform.position, -transform.up);
RaycastHit hit;
Physics.Raycast(ray, out hit);
if (hit.distance > distanceToOpenParachute)
{
parachutist.drag = 1f;
parachute.gameObject.SetActive(false);
}
else
{
parachutist.drag = dragAfterOpeningParachute;
parachute.gameObject.SetActive(true);
}
}
}
I dont understrand why,at first it works as well,but just after few seconds my parachutist’s ALREADY spawns with drag =3 and “opened parachute” Why?