111
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"version": 1,
|
||||
"name": "Player",
|
||||
"name": "PlayerInputActions",
|
||||
"maps": [
|
||||
{
|
||||
"name": "Controller",
|
||||
"name": "Player",
|
||||
"id": "3bb72885-24d6-4ee0-91c8-d1db20a0d89e",
|
||||
"actions": [
|
||||
{
|
||||
@@ -133,7 +133,7 @@ GameObject:
|
||||
- component: {fileID: 91895208}
|
||||
m_Layer: 0
|
||||
m_Name: Forward
|
||||
m_TagString: Player
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -539,7 +539,7 @@ GameObject:
|
||||
- component: {fileID: 679676968}
|
||||
m_Layer: 0
|
||||
m_Name: Capsule
|
||||
m_TagString: Player
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -821,7 +821,7 @@ GameObject:
|
||||
- component: {fileID: 1390492694}
|
||||
m_Layer: 0
|
||||
m_Name: Model
|
||||
m_TagString: Player
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -855,7 +855,7 @@ GameObject:
|
||||
- component: {fileID: 1414446908}
|
||||
m_Layer: 0
|
||||
m_Name: Virtual Camera
|
||||
m_TagString: Player
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -1121,7 +1121,7 @@ MonoBehaviour:
|
||||
m_ActionName: Controller/Pick[/Keyboard/f]
|
||||
m_NeverAutoSwitchControlSchemes: 0
|
||||
m_DefaultControlScheme:
|
||||
m_DefaultActionMap: Controller
|
||||
m_DefaultActionMap: 3bb72885-24d6-4ee0-91c8-d1db20a0d89e
|
||||
m_SplitScreenIndex: -1
|
||||
m_Camera: {fileID: 0}
|
||||
--- !u!114 &2046150437
|
||||
@@ -1137,20 +1137,13 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
characterController: {fileID: 2046150434}
|
||||
animator: {fileID: 0}
|
||||
forward: {fileID: 91895208}
|
||||
model: {fileID: 1390492694}
|
||||
hitItems: []
|
||||
vCam: {fileID: 1414446907}
|
||||
moveSpeed: 5
|
||||
jumpSpeed: 2
|
||||
turnSpeed: 10
|
||||
gravity: 10
|
||||
maxDistance: 100
|
||||
layerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
areaPick: 0
|
||||
--- !u!1 &2094812806
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94148b451f3cd28429d6e1540ba2ecf7
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -24,7 +24,7 @@ namespace StudyCase2
|
||||
model = transform.Find("Model");
|
||||
animator = model.GetComponentInChildren<Animator>();
|
||||
vCam = transform.Find("Virtual Camera").GetComponent<Cinemachine.CinemachineVirtualCamera>();
|
||||
inputAction = Resources.Load<InputActionAsset>("Player");
|
||||
inputAction = Resources.Load<InputActionAsset>("PlayerInputActions");
|
||||
inputAction.FindAction("Move").started += OnMove;
|
||||
inputAction.FindAction("Move").performed += OnMove;
|
||||
inputAction.FindAction("Move").canceled += OnMove;
|
||||
@@ -55,7 +55,7 @@ namespace StudyCase2
|
||||
}
|
||||
public void OnJump(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed && characterController.isGrounded)
|
||||
if (characterController.isGrounded)
|
||||
{
|
||||
moveDir.y = jumpSpeed;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace StudyCase3
|
||||
model = transform.Find("Model");
|
||||
animator = model.GetComponentInChildren<Animator>();
|
||||
vCam = transform.Find("Virtual Camera").GetComponent<Cinemachine.CinemachineVirtualCamera>();
|
||||
inputAction = Resources.Load<InputActionAsset>("Player");
|
||||
inputAction = Resources.Load<InputActionAsset>("PlayerInputActions");
|
||||
inputAction.FindAction("Move").started += OnMove;
|
||||
inputAction.FindAction("Move").performed += OnMove;
|
||||
inputAction.FindAction("Move").canceled += OnMove;
|
||||
@@ -49,6 +49,12 @@ namespace StudyCase3
|
||||
inputAction.FindAction("Pick").performed += OnPickUp;
|
||||
inputAction.Enable();
|
||||
itemRoot = transform.Find("ItemRoot");
|
||||
if (lineRenderer == null)
|
||||
{
|
||||
lineRenderer = gameObject.AddComponent<LineRenderer>();
|
||||
lineRenderer.material = new Material(Shader.Find("Universal Render Pipeline/2D/Sprite-Unlit-Default"));
|
||||
lineRenderer.useWorldSpace = true;
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
@@ -95,7 +101,12 @@ namespace StudyCase3
|
||||
}
|
||||
void CheckRayHit()
|
||||
{
|
||||
if (pickMode != PickMode.RayCast) return;
|
||||
lineRenderer.enabled = useDrawRay;
|
||||
if (pickMode != PickMode.RayCast)
|
||||
{
|
||||
useDrawRay = false;
|
||||
return;
|
||||
}
|
||||
Ray ray = new Ray(model.position, model.forward);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, maxDistance, layerMask))
|
||||
@@ -120,17 +131,6 @@ namespace StudyCase3
|
||||
}
|
||||
void DrawRay(Vector3 startPos, Vector3 endPos, Color color)
|
||||
{
|
||||
if (lineRenderer == null)
|
||||
{
|
||||
lineRenderer = gameObject.AddComponent<LineRenderer>();
|
||||
lineRenderer.material = new Material(Shader.Find("Universal Render Pipeline/2D/Sprite-Unlit-Default"));
|
||||
lineRenderer.useWorldSpace = true;
|
||||
}
|
||||
if (!useDrawRay)
|
||||
{
|
||||
lineRenderer.enabled = false;
|
||||
return;
|
||||
}
|
||||
lineRenderer.startColor = lineRenderer.endColor = color;
|
||||
lineRenderer.startWidth = lineRenderer.endWidth = 0.1f;
|
||||
lineRenderer.positionCount = 2;
|
||||
|
||||
Reference in New Issue
Block a user