How to make a straight wall

I need help. I’m trying to make a custom game that includes 2 separate lanes. does anyone know, a) How to make it so that if you touch a beam you get knocked back, or b) a better solution. Thanks!

2 ways to do this (checking if the player is between 2 lines), 1 hard and 1 easy. To be clear you don’t need the Y value (height or the middle value in a vector (0,0,0)) but for easyest understaning i will use A(x,y) or Xa, Ya for positions of points.

1- The easyest way is if the wall are lined up with the axis X or Y, then you just have to check if the X value of the player is > or < of the Xwall value (same if it’s lined up with the Y axis)

2- The hardest way is if it’s not lines up, then you will have to do some quick math (don’t worry i will type all formula you need to apply :wink: ) :

For this case you will need to have 2 vector (coordinates) for each walls (will make example for one but the following parts are the same for the two wall). Take the points as far as possible from each others to reduce the rounding error in calculus


The following part is not code, so use a calculator for this !

So you got A(x,y) and B(x,y), you need to determine the equation of a line ( y = ax+b) to get “a” and “b” values

first we search “a” : a = (Yb-Ya)/(Xb-Xa) <- save the result we need it after
Then “b” = Ya - (Xa*a) <- also save the result


So now we have the “a” and “b” value of you line we can check if the player is above or under this line, for that we do (will use Xp and Yp for current player pos) :

If : Yp - ((a*Xp)+b < 0 then the player is under the line
If : Yp - ((a*Xp)+b > 0 then the player is above the line

And that all, you got your wall and the way to check if the player is above or under the line (you can create a beam effect between A(x,y) and B(x,y) to shwo it)

If you have any question, i’m here ! (may take some time to respond)

1 Like
  • you mean the Z axis, as the Y axis is vertical.

If this way doest work for you, there is another one:
Your wall is probably something like a beam, that goes from position X to position Y. X and Y are vectors(x, y, z). Then you can do the following:

  • flaten (eliminate the y component) X, Y and the position of the event player with multiply(position of(event player), vector(1, 0, 1)). Lets call them X’, Y’ and player’.
  • create a vector from the event player to each of the wall positions (X’, Y’) with subtract(X’, player’) and subtract(Y’, player’). Lets call them P->X and P->Y.
  • if the angle between P->X and P->Y is 180°, the player touches the wall. In practise you have to check for >= 178° or something similar.

So, the condition for the rule looks like that: angle between vectors(subtract(multiply(X, vector(1, 0, 1)), multiply(position of(event player), vector(1, 0, 1))), subtract(multiply(Y, vector(1, 0, 1)), multiply(position of(event player), vector(1, 0, 1)))) >= 178°

That’s what i tried to explain here : and i find it easier to work with (x,y) than (x,z) but i guess it may be confusing

And your solution is great, until the player use a tp abylity and pass across the wall without toutching it. Also working with angle will result in an hibox being very close when near a wall vector but very large when you’r far away

1 Like

Yea, my bad sry.

True :slight_smile:

Can you explain this please?
Edit: Ok I understand what you mean now. Yes thats true, your solution is great and probably better overall.
The only advantage my way has is that the wall doesnt have infinite length. I just wanted to share my idea and it was meant as an alternative way :slight_smile:

Which is great if we want small portions of walls (and the angle effect wouldn’t be very noticable) but it still don’t fix the tp issue :confused:

Tried to explain this with a little schematic (for others who don’t understand) :
https: //puu. sh/ESsiH. jpg (delete space)

1 Like

Thanks alot guys, but I’m having a bit of trouble understanding the concepts, could you give me a level code as an example please?

Here : 40PCP

or the code is here :

variables
{
global:
	0: Wall_location
}

rule("Wall location")
{
event
{
	Ongoing - Global;
}

actions
{
	Set Global Variable At Index(Wall_location, 1, Vector(-63.173, 0.855, 87.064));
	Set Global Variable At Index(Wall_location, 2, Vector(-59.427, 2.289, 122.968));
}
}

rule("Beam effect")
{
event
{
	Ongoing - Global;
}

actions
{
	Create Beam Effect(All Players(All Teams), Good Beam, Value In Array(Global Variable(Wall_location), 1), Value In Array(
		Global Variable(Wall_location), 2), White, Visible To Position and Radius);
}
}

rule("Checking")
{
event
{
	Ongoing - Each Player;
	All;
	All;
}

conditions
{
	Subtract(Z Component Of(Position Of(Event Player)), Add(Multiply(9.584, X Component Of(Position Of(Event Player))), 692.553)) < 0;
}

actions
{
	Big Message(All Players(All Teams), Custom String("TEST", Null, Null, Null));
}
}

rule("Checking")
{
event
{
	Ongoing - Each Player;
	All;
	All;
}

conditions
{
	Subtract(Z Component Of(Position Of(Event Player)), Add(Multiply(9.584, X Component Of(Position Of(Event Player))), 692.553)) > 0;
}

actions
{
	Big Message(All Players(All Teams), Custom String("TEST 2", Null, Null, Null));
}
}

this condition : “Subtract(Z Component Of(Position Of(Event Player)), Add(Multiply(9.584, X Component Of(Position Of(Event Player))), 692.553)) > 0” is the “Yp-(a*Xp+b)”

The value 9.584 is the “a” and i get it with : a = (Yb-Ya)/(Xb-Xa) = (122.968-87.064)/(-59.4427+63.173)
And the value “b” (692.553) is obtain with : b = Ya - a*Xa = 87.064 - 9.584*(-63.173)

Hope it helps you

1 Like

Thanks! I’ll try it out

Edit: For some reason it thinks that I’m always touching the wall, please help me, though I’m not sure if yours would work anyway, I need something that doesn’t stretch across the whole map

Try to change the “> 0” to a “< 0” at the end of the condition, and yeah the fact it stretch through the whole map is one downsight of this methode, we may need to combine our 2 method to make this work

Ps: reply to the comment otherwise we don’t have any notification that you edited you post (you’r lucky i checked)

Edit : simple question, do you have hero who can tp in your gamemode ? like sombra/tracer/reaper/symm ?

Yes, i do have heroes that can teleport, but I was gonna get rid of the teleport abilities because they would be OP in my game mode (I’m trying to make a MOBA, I want a wall to separate the lanes). I need something that’s not infinite, but I don’t understand Shanalotte’s idea. That’s mostly what I wanted help with with the level code.

Try with this HN858, the detection is a bit chunky but i work.
It detect only between the 2 points.

1 Like

Oof, that’s a big condition

Edit: It worked great thanks!

1 Like

thank you thank you!! for adding the code line ‘example’ so we can see how it would read in the rule; and explaining in such detail. I know nadda about programming , and have no clue what I am supposed to do when told in vague terms something like “create a vector” .

1 Like

so much pardon I should beg, but the use of Y for Z and other odd phrasing made my brain hurt to puzzle out. So this is reorganized in a way that makes sense to me and hopefully other very clueless noobs that cannot not use the same letter to mean two different things in different calcs… :slight_smile: think it all means:
** opps i had some reversed calc’s and put some wrong numbers in but i think i have them fix on edit. **
To build an imaginary wall you must define the wall placement.
To help u discover map vectors you can create and play with some effect sphere markers.
write down their X + Z vectors u decide on for later coding:
Example used:
marker A: Xa 81.687 Za -75.34
marker B: Xb 82.670 Zb -65.352
need to calculate:
(Xb-Xa)=Xn = wall span on X vector = 0.99
(Zb-Za)=Zn = wall span on Z vector = 9.98
(neg minus neg always mess me up: might be -104.692 )
[1st value] D = (Xb-Xa)/ (Zb-Za) << i think or reverse? >
if I’m right D = 9.988 / .99 = 10.088
[2nd value] #F = Za -( Xa * D ) =
= -75.34 -(81.687*10.088 ) = - 899.398
<< might be grouped wrong but i think it good

[Every placement needs these two values calculate specific to that map & wall ] correct? to give diff variables for other walls in other places.
The xyz of event player can then show if hero is trying to enter the area u define as a wall.
(The rule functions will auto-define event player xyz.)
To mathematically decide if a hero is ‘intruding’ on the ‘wall’ a rule action will use the values u supply to ask for an interact calculation which mathematically is: Zp-(D*Xp+F) >0 ?
[you must provide the real # value of D & F which change for every wall) . If the equation >0 the hero is ‘in’ the wall.

does this rule itself only cause the wall to build right? and chek itself?
or is it used as a condition to instruct the game to do the action to defend the wall?
“Subtract(Z Component Of(Position Of(Event Player)), Add(Multiply(10.160, X Component Of(Position Of(Event Player))), -899.398)) > 0”
<< change real values where needed
in plain English to me that means subtract from the hero Z vector a total value that comes from adding
D * Xp to F
then it decides if it is greater than 0.
if i got that all right way round it will make a number to compare to 0.
. do we need more conditions for the response? or can we just take this conditions and put it with an action to cause the response?
:smile: i still feel like i’m missing a factor somewhere that i didn’t catch amid the confusion of duplicate factors having differing purposes.
HOPE I GOT IT RIGHT