How to make sphere not go into the air

So i have a sphere that follows you where you’re looking. But i do not want it so when you look it it goes up i want it to stay on the ground but i’m not sure how i would do that. Heres what i have

actions
{
Create Effect(All Players(All Teams), Sphere, White, Ray Cast Hit Position(Eye Position(Event Player), Eye Position(Event Player)
+ Facing Direction Of(Event Player) * 12, All Players(All Teams), Event Player, True), 1, Visible To Position and Radius);
}

You could do another raycast to the ground, wich would be the most accurate, but also very resource intensive.
You could also take the “nearest walkable position” of it, but that might give you a position on highgrounds sometimes.

The first, most accurate solution:

Ray Cast Hit Position(Ray Cast Hit Position(Eye Position(Event Player), Eye Position(Event Player) + Facing Direction Of(Event Player) * 12, All Players(All Teams), Event Player, True), Ray Cast Hit Position(Eye Position(Event Player), Eye Position(Event Player) + Facing Direction Of(Event Player) * 12, All Players(All Teams), Event Player, True) + Vector(0, -50, 0))

But the performance is probably horrible.

You can simplify this (and improve the performance) in multiple ways, but you will always lose some accuracy. For example you could replace some of the raycast by simply adding some vectors together. Or you could try the “nearest walkable position” solution and see if its good enough for your purpose:

Nearest Walkable Position(Ray Cast Hit Position(Eye Position(Event Player), Eye Position(Event Player) + Facing Direction Of(Event Player) * 12, All Players(All Teams), Event Player, True))

Another way to simplify would be the looping method:

Create Effect(..., Event Player.effectPosition, ...);
While(Not(*condition that ends the effect thing*));
Event Player.effectPosition = Ray Cast Hit Position(Eye Position(Event Player), Eye Position(Event Player) + Facing Direction Of(Event Player) * 12, All Players(All Teams), Event Player, True);
Event Player.effectPosition = Ray Cast Hit Position(Event Player.effectPosition, Event Player.effectPosition + Vector(0, -50, 0));
Wait(0.250, Ignore Condition);
End;

Ok thank you i think ill just use the walkable position thing, i wanna use the least amount of elements as possible

1 Like