Hello, I am trying to find the y position of a foundation (placed within the game) by using Raycasts. However, I get an error:
How can I use Raycasts in my plugin?Code:'ConVar.Physics' does not contain a definition for 'Raycast'
Relevant code:
Sorry, if this is a stupid questionCode:public static float GetGroundY(BuildingBlock block) { RaycastHit hitinfo; var position = block.transform.position; if (Physics.Raycast(position, new Vector3(0f, -1f, 0f), out hitinfo, 100f, UnityEngine.LayerMask.GetMask(new string[] { "Terrain" }))) { return hitinfo.point.y; } return position.y; }
How to use Raycasts?
Discussion in 'Rust Development' started by hennieben, Feb 20, 2016.
-
do you want the position y of the foundation or of the ground at that position?
-
The foundation. I am *Attempting* to create a plugin that enables the user to raise foundations without having to destroy them all
-
So you want to get the ground height or the foundation height position?Last edited by a moderator: Feb 26, 2016
-
foundation height position
-
just use foundationEntity.transform.position.y then. No need to use Raycast there.
-
How would I find the maximum height that the foundation can be placed at (at its current position)?Last edited by a moderator: Feb 20, 2016
