#6 Default Gerstner Wave

This commit is contained in:
M1_IDMhan 2023-08-03 10:03:08 +09:00
parent 922ed8e56e
commit 3973258f79
15 changed files with 581 additions and 1119 deletions

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
],
""bindings"": [
{
""name"": ""2D Vector"",
""name"": ""WASD"",
""id"": ""4dc5b54c-0e59-461e-a12d-470900925a36"",
""path"": ""2DVector"",
""interactions"": """",

View File

@ -17,7 +17,7 @@
],
"bindings": [
{
"name": "2D Vector",
"name": "WASD",
"id": "4dc5b54c-0e59-461e-a12d-470900925a36",
"path": "2DVector",
"interactions": "",

View File

@ -8,12 +8,12 @@ public class Floater : MonoBehaviour
public float boatOffset = 0.0f; // new variable
private Rigidbody rb;
void Start()
private void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
public void Update()
{
float waveNumber = 2.0f * Mathf.PI / waveGenerator.waveLength;
float phaseConstant = waveGenerator.speed * waveNumber;
@ -34,4 +34,4 @@ public class Floater : MonoBehaviour
Quaternion targetRotation = Quaternion.FromToRotation(transform.up, normal) * transform.rotation;
rb.MoveRotation(Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * waveGenerator.speed));
}
}
}

View File

@ -9,7 +9,7 @@ public class GerstnerWave : MonoBehaviour
public float speed = 1f;
public Vector2 direction = new Vector2(1.0f, 0.0f);
void Update()
public void Update()
{
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;

View File

@ -0,0 +1,36 @@
using UnityEngine;
using UnityEngine.InputSystem;
namespace _02.Scripts.WaterAndShip
{
public class Player : MonoBehaviour
{
public float speed = 10f;
public float turnSpeed = 10f;
private Rigidbody rb;
private Vector2 movementInput;
void Awake()
{
rb = GetComponent<Rigidbody>();
}
public void OnMove(InputValue value)
{
movementInput = value.Get<Vector2>();
}
void FixedUpdate()
{
Vector3 movement = new Vector3(movementInput.x, 0.0f, movementInput.y);
// Move the boat
rb.AddForce(movement * speed * Time.fixedDeltaTime, ForceMode.VelocityChange);
// Rotate the boat
float turn = movementInput.x;
Quaternion turnRotation = Quaternion.Euler(0f, turn * turnSpeed, 0f);
rb.MoveRotation(rb.rotation * turnRotation);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 176cfac66084d4bfb9b4c9f11c4b137f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -819,7 +819,8 @@ PlayerSettings:
tvOS: UNITY_POST_PROCESSING_STACK_V2
additionalCompilerArguments: {}
platformArchitecture: {}
scriptingBackend: {}
scriptingBackend:
Standalone: 1
il2cppCompilerConfiguration: {}
il2cppCodeGeneration: {}
managedStrippingLevel:
@ -920,7 +921,7 @@ PlayerSettings:
embeddedLinuxEnableGamepadInput: 1
hmiLogStartupTiming: 0
hmiCpuConfiguration:
apiCompatibilityLevel: 6
apiCompatibilityLevel: 3
activeInputHandler: 2
windowsGamepadBackendHint: 0
cloudProjectId: