Package net.risingworld.api.utils
Klasse RaycastResult
java.lang.Object
net.risingworld.api.utils.RaycastResult
Represents the result of a raycast.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungGets the collision normal, i.e the normal of the surface the ray hit.
This normal is already normalized.Gets the collision point, i.e the position where the ray hit a collider.
Note: If you want to get the world position of the hit object itself instead, seegetObjectPosition()
float
Gets the distance between the player (or more precisely, the origin of the ray) and the collision point.int
Gets the internal instance ID of the underlying Unity GameObject that was hit.int
getLayer()
Gets the hit layer.Gets the chunk coordinates where the element is located that was hit by this ray.long
Gets the global ID (of the element the ray collided with).Gets the world position of the element that was hit by this ray.int
Gets the triangle index of the hit element mesh.boolean
Gets whether or not a collision occurred.boolean
Gets whether or not the hit collider was a "trigger" (i.e a ghost collider).toString()
Gets a String representation of this RayCastResult.
-
Methodendetails
-
hasCollision
public boolean hasCollision()Gets whether or not a collision occurred. Usually it is not necessary to call this method, since in case that no collision occurred, there wouldn't be aRaycastResult
object (i.e the callback result would be null).- Gibt zurück:
- true if this object holds a result, false if not.
-
getDistance
public float getDistance()Gets the distance between the player (or more precisely, the origin of the ray) and the collision point. ReturnsFloat.MAX_VALUE
if no collision occurred (seehasCollision()
.- Gibt zurück:
- the distance to the collision point.
-
getLayer
public int getLayer()Gets the hit layer. If no collision occurred, this methods returns 0.- Gibt zurück:
- the layer of the object that was hit.
- Siehe auch:
-
getCollisionPoint
Gets the collision point, i.e the position where the ray hit a collider.
Note: If you want to get the world position of the hit object itself instead, seegetObjectPosition()
- Gibt zurück:
- the collision position as a
Vector3f
.
-
getCollisionNormal
Gets the collision normal, i.e the normal of the surface the ray hit.
This normal is already normalized.- Gibt zurück:
- the collision normal as a normalized
Vector3f
, or null if no collision occurred.
-
getInstanceID
public int getInstanceID()Gets the internal instance ID of the underlying Unity GameObject that was hit. The instance ID identifies the actual internal object. It's neither persistent nor identical between different players!- Gibt zurück:
- the internal Unity object instance ID (may be positive or negative).
- Siehe auch:
-
isTrigger
public boolean isTrigger()Gets whether or not the hit collider was a "trigger" (i.e a ghost collider).- Gibt zurück:
- true if the hit collider was a trigger, false if it's a solid collider.
-
getTriangleIndex
public int getTriangleIndex()Gets the triangle index of the hit element mesh.- Gibt zurück:
- the hit triangle index.
-
getObjectGlobalID
public long getObjectGlobalID()Gets the global ID (of the element the ray collided with). This only works for elements which have an id (e.g objects, construction elements, plants, npc etc).- Gibt zurück:
- the element type id, or -1 if no collision occurred or if the object does not have a type id (e.g terrain, water, grass etc).
- Siehe auch:
-
getObjectPosition
Gets the world position of the element that was hit by this ray. Not to be confused with the collision point, which is the actual point where the collision occurred.- Gibt zurück:
- the world position of the hit element.
- Siehe auch:
-
getObjectChunkPosition
Gets the chunk coordinates where the element is located that was hit by this ray. If we hit an object (like furniture), a construction element (like a block) or a plant, we can use the chunk position in combination withgetObjectGlobalID()
to get the object instance (e.g fromWorld.getObject(long, int, int, int)
orWorld.getConstructionElement(long, int, int, int)
.- Gibt zurück:
- the chunk coordinates of the hit element.
- Siehe auch:
-
toString
Gets a String representation of this RayCastResult.
-