#15 Ready to movement in ship

This commit is contained in:
M1_IDMhan 2023-08-10 22:33:10 +09:00
parent 8af4158f44
commit a15e8cf91e
6 changed files with 1119 additions and 15 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,10 +15,11 @@ public class DraggableCard : MonoBehaviour, IPointerDownHandler, IDragHandler, I
public void OnPointerDown(PointerEventData eventData) public void OnPointerDown(PointerEventData eventData)
{ {
originalPosition = transform.position; var transform1 = transform;
originalScale = transform.localScale; originalPosition = transform1.position;
originalScale = transform1.localScale;
canvasGroup.alpha = 0.5f; canvasGroup.alpha = 0.5f;
transform.localScale = new Vector3(0.3f, 0.3f, 1f); transform1.localScale = new Vector3(0.3f, 0.3f, 1f);
} }
public void OnDrag(PointerEventData eventData) public void OnDrag(PointerEventData eventData)
@ -26,7 +27,7 @@ public class DraggableCard : MonoBehaviour, IPointerDownHandler, IDragHandler, I
transform.position = Input.mousePosition; transform.position = Input.mousePosition;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit; RaycastHit hit;
if (Physics.Raycast(ray, out hit) && hit.collider.tag == "Ground") if (Physics.Raycast(ray, out hit) && hit.collider.CompareTag("Ground"))
{ {
// 마우스가 Ground 위에 있을 때 // 마우스가 Ground 위에 있을 때
@ -38,8 +39,9 @@ public class DraggableCard : MonoBehaviour, IPointerDownHandler, IDragHandler, I
// 지형에 올바르게 드롭되지 않으면 // 지형에 올바르게 드롭되지 않으면
if (!IsDroppedOnTarget()) if (!IsDroppedOnTarget())
{ {
transform.position = originalPosition; var transform1 = transform;
transform.localScale = originalScale; transform1.position = originalPosition;
transform1.localScale = originalScale;
canvasGroup.alpha = 1; canvasGroup.alpha = 1;
} }
} }
@ -51,7 +53,7 @@ public class DraggableCard : MonoBehaviour, IPointerDownHandler, IDragHandler, I
if (Physics.Raycast(ray, out hit)) if (Physics.Raycast(ray, out hit))
{ {
if (hit.collider.tag == "Ground") if (hit.collider.CompareTag("Ground"))
{ {
Destroy(gameObject); Destroy(gameObject);
return true; return true;

View File

@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class Floater : MonoBehaviour public class Floater : MonoBehaviour
{ {
private GerstnerWave waveGenerator; private GerstnerWave waveGenerator;

View File

@ -4,6 +4,8 @@ using UnityEngine.InputSystem;
namespace _02.Scripts.WaterAndShip namespace _02.Scripts.WaterAndShip
{ {
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(PlayerInput))]
public class Player : MonoBehaviour public class Player : MonoBehaviour
{ {
public float maxSpeed = 10f; public float maxSpeed = 10f;

View File

@ -36,6 +36,7 @@ Material:
RenderType: Transparent RenderType: Transparent
disabledShaderPasses: disabledShaderPasses:
- DepthOnly - DepthOnly
- SHADOWCASTER
m_LockedProperties: m_LockedProperties:
m_SavedProperties: m_SavedProperties:
serializedVersion: 3 serializedVersion: 3
@ -132,7 +133,7 @@ Material:
- _ZWrite: 0 - _ZWrite: 0
m_Colors: m_Colors:
- _BaseColor: {r: 0.454902, g: 0.454902, b: 0.454902, a: 1} - _BaseColor: {r: 0.454902, g: 0.454902, b: 0.454902, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 0.454902, g: 0.454902, b: 0.454902, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []

View File

@ -117,7 +117,7 @@ Material:
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
- _BaseColor: {r: 0, g: 0.666667, b: 1, a: 1} - _BaseColor: {r: 0, g: 0.666667, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 0, g: 0.666667, b: 1, a: 1}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []