Ok so heres the thing, after 3 days of failing with formulas and crunching different methods of math. I’ve come to a point where I’m outta juice. So i hope there’s some1 who can help me.
Ok then. When the player jumps to a ledge there’s a trigger that enables the player to “grab” the edge.
The edge can be placed at a varying distance so the script is gonna have to fix the position of the player.
The above picture is the result so far, the green line is the trigger. The pink line is a Debug.DrawLine of the formula i used.
I want that pink line to only go to the edge of the trigger but w/e formula i try keeps making it go out of the box.
Heres the code i’ve worked on:
if(triggerID.tag=="triggerEdgeClimb"&Input.GetKey(KeyCode.E)||trigger_firstPass){
this.transform.rotation=triggerID.transform.rotation;
if(trigger_firstPass==false){
edgeTriggerTimer=0;
trigger_firstPass=true;
positionStore=this.transform.position;
}
this.transform.position=Vector3.Lerp(
/*From*/ positionStore,
/*To*/ triggerID.transform.TransformDirection(
Vector3(0,0,
triggerID.transform.localScale.z-(
1.0f-triggerID.transform.localScale.z
)
)
)+
positionStore,
//her position relative to the trigger in Z,
/*???*/ edgeTriggerTimer
);
edgeTriggerTimer+=(Time.deltaTime/2);
}
i excluded the part where i use DrawLine() since it contains the same information.
So some1 plz shed some light on this for me!