How to create a Ray cast that goes through walls?

Title. Been trying for a while and messing around with all the vector and direction codes, kept on failing bc console buttons. Just to clarify, I don’t want this to hit players, just to be a line straight forward from variable A to variable B that goes a certain distance without stopping on walls.

1 Like

You just need to create a vector with the length you want. You can ignore ray cast completely since that is to detect collision in the environment, optional players and player-owned objects. You can use the Direction Towards value, and multiply it by the distance you want. Here’s an example:

actions
{
	Event Player.C = Direction Towards(Event Player.A, Event Player.B) * 20;
}

You can change 20 to any length you want, and that will be the length between A to B, optionally going beyond B. Direction Towards creates a vector in the direction from A to B that is a length of 1. By multiplying it by a value, you create a vector that is that exact length, since, for example, 20 * 1 = 20.

1 Like

Ah, can’t believe I missed something so simple!:pensive: I’ve learnt to understand a lot of things over these last few years but I still struggle with vectors. Thanks for this!

1 Like

If you struggle with Vector Math, triogonometry, to a slight instance of Calculus 1 and 2 (especially for interpolation) or Linear Algebra i would recommend watching out for some audio-visual tutorials in the internet, there are a variaty of really helpful also in contex of Game Design and programming languages (mostly for Python if i remember) or even game engines of course, to create and work your own spreadsheet which you can track back on to basic formulas if you stuck at any time if needed. For some Vector Math i found a nice introduction explanation of Vector Math by Freya Holmér: Math For Game Devs - YouTube

1 Like