PLAYER SCRIPT
SCRIPT NEEDS TO ACCOMPLISH...
Create a variable to hold the sphere prefab
Method for what happens when we left click
Raycast w/ origin of Mouse Position
HitInfo to detect the floor
Instantiate sphere at hit point
CODE BREAKDOWN
LINE 14 - 26 ==> If statement that is ran when the user presses the left mouse button
LINE 16 --> Creates a Vector2 type variable to hold the position of the mouse
LINE 17 --> Defines the starting point of the ray [rayOrigin]
LINE 18 --> Structure used to get information back from a raycast collision [RaycastHit]
LINE 21 - 25 ==> If statement that returns true when the ray intersects into any collider [Raycast Declaration]
LINE 23 --> Access the extracted information in
hitInfo
to display the Objects name in the Unity ConsoleLINE 24 --> instantiates the sphere prefab at the point of intersection of the raycast and the floor
hitInfo.point --> the impact point in the world space where the ray hit the collider
quaternion --> Quaternions are vectors used to compute rotations in software.
quaternion.identity --> The quaternion identity is the default or none value to the objects rotation. By setting the rotation of a new object to this value, it ensures that the new object will be in its "natural" orientation.
Last updated