Get the height of a pillar?

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
Bhf I don't even know how to but I guess if it's possible it's something with UnityEngine and that won't be easy. Why would you need to get the height ?
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
So if a Pillar is over *Insert number here* high it is destroyed.
I can get to be destroyed if greater than 300 by doing:
JavaScript:
if (300 < Enitiy.Y){
}
Just need to know how to get the height starting at a foundation

EDIT: At first I thought World.GetGround would work, Nope :p
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
So if a Pillar is over *Insert number here* high it is destroyed.
I can get to be destroyed if greater than 300 by doing:
JavaScript:
if (300 < Enitiy.Y){
}
Just need to know how to get the height starting at a foundation

EDIT: At first I thought World.GetGround would work, Nope :p
I see what you mean, but why doesn't it work ?
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
C#:
    public float GetGround(float x, float z)
    {
      return this.GetGroundDist(x, float.MaxValue, z);
    }

    public float GetGroundDist(Vector3 vector3)
    {
      return this.GetGroundDist(vector3.x, vector3.y, vector3.z);
    }

    public float GetGroundDist(float x, float y, float z)
    {
      RaycastHit hitInfo;
      if (Physics.Raycast(new Vector3(x, y, z), Vector3.down, out hitInfo))
        return hitInfo.distance;
      else
        return float.NaN;
    }
As I can see in the code it returns the point that collisions from max height down to the bottom, so if you are on top of a building it will return it's pos. You can also make an option to "ignore" collisions with buildings and get the real ground height, but that should be made in the fougerite assembly.
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Yes but you need to give it an x axis and a z axis for it to get the Y axis. I guess it is World.GetGround(float x, float z).
if((World.GetGround(Entity.X, Entity.Z) + 8) < Entity.Y){
Would that count 8 high from a foundation?