i am trying to make a parkour system but i have this situation:
here i canJump = false.
here canJump = true.
this is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public RayChecker[] checkers;
bool canJump;
float checkDistance = 10f;
int any;
void Start(){
for(int i = 0; i < checkers.Length; i++){
if(checkers *== null){*
checkers = new RayChecker();
checkers_.position.y = i * 0.5f;
}
}
}_
void Update(){
for(int i = 0; i < checkers.Length; i++){
RaycastHit hit;
checkers_.activated = Physics.Raycast(checkers*.position + transform.position, transform.forward, out hit, checkDistance);*
Debug.DrawRay(checkers.position + transform.position, transform.forward * hit.distance, Color.cyan);_
any = i;
}
if(checkers[any].activated != false){
canJump = true;
}
else if(checkers[any].activated == false){
canJump = false;
}
}
}
the RayChekers are ScriptableObjects:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class RayChecker : ScriptableObject
{
public Vector3 position;
public bool activated;
}