I have a red raycast that has an endpoint
I also have a blue shapecast with a collision point
How do I find the ? in the crappy diagram I drew?
At the moment my code is a complete jumbled mess. i have no clue what im doing help
look_cast is the the red raycast and vaulter is the blue shapecast.
The red raycast is parented to my camera and the shapecast to my body.
The square is a collision box.
Code:
func vault():
#Make Vars
var vaulter_point:Vector3
var look_cast_point:Vector3
#Get Var Values
vaulter_point = vaulter.get_collision_point(0)
if look_cast.is_colliding():
look_cast_point = look_cast.get_collision_point()
else:
look_cast_point = look_cast.target_position
#Project Them
var dist = (look_cast_point - global_position).length()
var wish_dist = dist/cos(look_cast.rotation.x)
var x_point = look_cast.global_position - look_cast.global_basis.z * (wish_dist + 0.1)
vault_cast.position = x_point
vault_cast.target_position.y = vaulter_point.y - vault_cast.position.y
print(wish_dist)
if vault_cast.is_colliding():
velocity += vault_cast.get_collision_point() - global_position