mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-05-15 07:34:46 +00:00
Fix typos
This commit is contained in:
parent
76550dfa3c
commit
5c0799df7f
118 changed files with 1150 additions and 1602 deletions
|
@ -1,6 +1,6 @@
|
|||
# Raycasting Notes
|
||||
|
||||
A raycast is conceptually like a laser beam that is fired from a point in space along a particular directuin. Any object making contact with the beam can be detected and reported.
|
||||
A raycast is conceptually like a laser beam that is fired from a point in space along a particular direction. Any object making contact with the beam can be detected and reported.
|
||||
|
||||
## 3D Raycasting
|
||||
|
||||
|
@ -16,13 +16,13 @@ void Update()
|
|||
hitInfo.transform // transform og the hit object
|
||||
hitInfo.collider.gameObject // reference to the object hit by the ray
|
||||
hitInfo.collider.gameObject // reference to the object hit by the ray
|
||||
hitInfo.normal // normal bector og the hit surface
|
||||
hitInfo.normal // normal vector og the hit surface
|
||||
hitInfo.point // actual point of collision
|
||||
|
||||
// static method, object must haave a collider dot the collision to happen, returns a BOOL
|
||||
// static method, object must have a collider dot the collision to happen, returns a BOOL
|
||||
Physics.Raycast(ray, out hitInfo); // update hitInfo based on ray collisions
|
||||
Physics.Raycast(ray, out hitInfo, float maxRayDistance); // limit the ray length
|
||||
Physics.Raycast(ray, out hitInfo, Mask mask); // specify with which layers the ray can interact, layer must be allpied to object's mask
|
||||
Physics.Raycast(ray, out hitInfo, Mask mask); // specify with which layers the ray can interact, layer must be applied to object's mask
|
||||
Physics.Raycast(ray, out hitInfo, Mask mask, QueryTriggerInteraction.Ignore); // ignore collision if "is trigger" is enabled on other objects
|
||||
|
||||
// detect a collision
|
||||
|
@ -30,12 +30,12 @@ void Update()
|
|||
{
|
||||
//collision happened
|
||||
|
||||
// draw the ray ingame for debuggng
|
||||
// draw the ray in game for debugging
|
||||
Debug.DrawLine(ray.origin, hitInfo.point, Color.red); // draw red line if collision happens
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.DrawLine(ray.origin, ray.origin + ray.direction * 100, Color.blue); // draw blue line if collision happens, arrival point is 100 units from the origin sinche the ray goes to infinity
|
||||
Debug.DrawLine(ray.origin, ray.origin + ray.direction * 100, Color.blue); // draw blue line if collision happens, arrival point is 100 units from the origin since the ray goes to infinity
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -47,8 +47,8 @@ public Camera gameCamera;
|
|||
|
||||
void Update()
|
||||
{
|
||||
// ray goint ftom cametra through a screen point
|
||||
Ray ray = gameCamera.ScreenPointToRay(Input.mousePosition); // Input.mousePosition is the postion of the mouse in pixels (screen points)
|
||||
// ray going from camera through a screen point
|
||||
Ray ray = gameCamera.ScreenPointToRay(Input.mousePosition); // Input.mousePosition is the position of the mouse in pixels (screen points)
|
||||
RaycastHit hitInfo; // place pointed by the mouse
|
||||
|
||||
Physics.Raycast(ray, out hitInfo) // update pointed position
|
||||
|
@ -61,12 +61,12 @@ void Update()
|
|||
|
||||
void Start()
|
||||
{
|
||||
Physisc2D.queriesStartColliders = false; // avoid collision with collider of the ray generator gameObject
|
||||
Physics2D.queriesStartColliders = false; // avoid collision with collider of the ray generator gameObject
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// returns a RaycastHit2D, needs an origin and direction separatedly
|
||||
// returns a RaycastHit2D, needs an origin and direction separately
|
||||
Raycast2D hitInfo = Physics2D.Raycast(Vector2 origin, Vector2 direction);
|
||||
Raycast2D hitInfo = Physics2D.Raycast(Vector2 origin, Vector2 direction, float maxRayDistance);
|
||||
Raycast2D hitInfo = Physics2D.Raycast(Vector2 origin, Vector2 direction, float maxRayDistance);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue