Help with Ray Cast Position

I’m trying to replicate the teleporter position / Mei wall placement targeting. I am very close. So far I have this:

actions
{
	Create Effect(Event Player, Sphere, Purple, Ray Cast Hit Position(Ray Cast Hit Position(Eye Position(Event Player), Eye Position(
		Event Player) + Facing Direction Of(Event Player) * 20, Null, Null, False), Ray Cast Hit Position(Eye Position(Event Player),
		Eye Position(Event Player) + Facing Direction Of(Event Player) * 20, Null, Null, False) + Vector(0, -100, 0), Null, Null,
		False), 1, Visible To Position and Radius);
}

This “works”, but has the following problems:

  • I have to duplicate this Ray Cast just to apply an offset to the outer Ray Cast’s End Pos from Start Pos. My Goal here is to look for the ground below where the player is aiming:
Ray Cast Hit Position(Eye Position(Event Player),
		Eye Position(Event Player) + Facing Direction Of(Event Player) * 20, Null, Null, False) + Vector(0, -100, 0)

I tried to store the Ray Cast in a variable, but then the ReEvaulate part of Create Effect no longer works. So I setup another event rule that uses another duplicate of the Ray Cast as a condition to continually update the variable… But that is noticably slower (position doesn’t keep up with cross hairs).

I tried “Chase” but that doesn’t seem to work at all…?

  • My downward Raycast gets caught on very small geometry on walls. Like in the defenders spawn room of Hanamura point B there is molding on the walls that my sphere will attatch to.

Is there a way to make it prefer the ground next to the wall?

  • The sphere is a bit gittery, even with the ReEvalulate version. I mean, it sticks to the cursor perfectly. But for a milisecond the sphere sometimes dissapears only to reappear again. What’s causing that? It’s almost if sometimes my downward Raycast is not hititng the ground but actually going below the floor.

  • Maybe a dumb question but - How do I get it not to appear if the downward Raycast hits nothing? I’m going to assume I need to check the Y value to see if it is < -50 or something.

You could use Nearest Walkable Position of your ray cast :slight_smile:

For the downward RayCast? Wouldn’t that break being able to aim at the ground below when on high ground? (Like Numbani point A)

I feel like if you’re looking down, it’d be fine, but if you’re looking straight out horizontal, it may go to your feet if it’s closer than straight down.

I mean, what I have works. For the most part the orb is going exactly where I want. The issues are basically:

  • Avoiding duplicating the same Ray Casts
  • The Orb disappearing below the floor sometimes
  • The Orb attaching to the wall at some points.

I discovered why it is disappearing below the floor - The RayCast position coming from the player’s Eye is actually returning a value that is below the floor Geometry. So when I start the second Raycast downward, that second Raycast is actually starting below the floor. I think I can fix that one by adding something like 1.0 to the Y position to make it start up higher… Only idea I have at the moment.

With the Orb attaching to the wall, I think I can modify the X/Z positions of the first Raycast to pull it back towards the player a bit to give it a “margin” to not get caught on smaller geometry. I just don’t know exactly how to do that. My first thought is to use “Facing Direction Of” somehow to pull the vector back towards the player… but I have no idea how to do that… But I am a Vector noob and still figuring this stuff out :sweat:.

You need to use variables, wich implies using a loop to update the variables, wich then leads to the sphere lagging a little.

You could try adding facing direction(...) * -1 * length