Vectors hurt my brain

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 :pray:

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

Edit: Gave More Context
(This is a bump in disguise)

1 Like

u know math problem like
3x + 1 = 2x + 2?
both sides need to become y so it look like this:

y = 3x + 1 = y = 2x + 2
(u need to programm something that solves it)

Accept the variables ur using need to be the vector position.
U can describe a line as the following math function:
f(x) = m*x+b
b is the starting y coordinate
m describes how many squares per one x square on the coordinate system the line goes up
x describes on what square along the x axis the line is
The red line look like every x incrementation the line goes 0.5 squares up so it would be f(x) = 0.5x+b
the pink one doesnt have m at all and b doesnt matter so in math we would describe it as x = [float] (i dont know where the origin is)

1 Like

Accept the lines dont have the same rotation.y. If not, let me know

What is the pink line? Is it a line drawn from the point of collision between the shape cast and the collision box?

Ah, thank you.

I already found an alternative method for the thing I needed this for.
So, don’t worry about it