#6 Default Gerstner Wave
This commit is contained in:
parent
922ed8e56e
commit
3973258f79
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable
|
|||||||
],
|
],
|
||||||
""bindings"": [
|
""bindings"": [
|
||||||
{
|
{
|
||||||
""name"": ""2D Vector"",
|
""name"": ""WASD"",
|
||||||
""id"": ""4dc5b54c-0e59-461e-a12d-470900925a36"",
|
""id"": ""4dc5b54c-0e59-461e-a12d-470900925a36"",
|
||||||
""path"": ""2DVector"",
|
""path"": ""2DVector"",
|
||||||
""interactions"": """",
|
""interactions"": """",
|
@ -17,7 +17,7 @@
|
|||||||
],
|
],
|
||||||
"bindings": [
|
"bindings": [
|
||||||
{
|
{
|
||||||
"name": "2D Vector",
|
"name": "WASD",
|
||||||
"id": "4dc5b54c-0e59-461e-a12d-470900925a36",
|
"id": "4dc5b54c-0e59-461e-a12d-470900925a36",
|
||||||
"path": "2DVector",
|
"path": "2DVector",
|
||||||
"interactions": "",
|
"interactions": "",
|
@ -8,12 +8,12 @@ public class Floater : MonoBehaviour
|
|||||||
public float boatOffset = 0.0f; // new variable
|
public float boatOffset = 0.0f; // new variable
|
||||||
private Rigidbody rb;
|
private Rigidbody rb;
|
||||||
|
|
||||||
void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
rb = GetComponent<Rigidbody>();
|
rb = GetComponent<Rigidbody>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
float waveNumber = 2.0f * Mathf.PI / waveGenerator.waveLength;
|
float waveNumber = 2.0f * Mathf.PI / waveGenerator.waveLength;
|
||||||
float phaseConstant = waveGenerator.speed * waveNumber;
|
float phaseConstant = waveGenerator.speed * waveNumber;
|
||||||
@ -34,4 +34,4 @@ public class Floater : MonoBehaviour
|
|||||||
Quaternion targetRotation = Quaternion.FromToRotation(transform.up, normal) * transform.rotation;
|
Quaternion targetRotation = Quaternion.FromToRotation(transform.up, normal) * transform.rotation;
|
||||||
rb.MoveRotation(Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * waveGenerator.speed));
|
rb.MoveRotation(Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * waveGenerator.speed));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ public class GerstnerWave : MonoBehaviour
|
|||||||
public float speed = 1f;
|
public float speed = 1f;
|
||||||
public Vector2 direction = new Vector2(1.0f, 0.0f);
|
public Vector2 direction = new Vector2(1.0f, 0.0f);
|
||||||
|
|
||||||
void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
Mesh mesh = GetComponent<MeshFilter>().mesh;
|
Mesh mesh = GetComponent<MeshFilter>().mesh;
|
||||||
Vector3[] vertices = mesh.vertices;
|
Vector3[] vertices = mesh.vertices;
|
36
BlueWater/Assets/02.Scripts/WaterAndShip/Player.cs
Normal file
36
BlueWater/Assets/02.Scripts/WaterAndShip/Player.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
BlueWater/Assets/02.Scripts/WaterAndShip/Player.cs.meta
Normal file
11
BlueWater/Assets/02.Scripts/WaterAndShip/Player.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 176cfac66084d4bfb9b4c9f11c4b137f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -819,7 +819,8 @@ PlayerSettings:
|
|||||||
tvOS: UNITY_POST_PROCESSING_STACK_V2
|
tvOS: UNITY_POST_PROCESSING_STACK_V2
|
||||||
additionalCompilerArguments: {}
|
additionalCompilerArguments: {}
|
||||||
platformArchitecture: {}
|
platformArchitecture: {}
|
||||||
scriptingBackend: {}
|
scriptingBackend:
|
||||||
|
Standalone: 1
|
||||||
il2cppCompilerConfiguration: {}
|
il2cppCompilerConfiguration: {}
|
||||||
il2cppCodeGeneration: {}
|
il2cppCodeGeneration: {}
|
||||||
managedStrippingLevel:
|
managedStrippingLevel:
|
||||||
@ -920,7 +921,7 @@ PlayerSettings:
|
|||||||
embeddedLinuxEnableGamepadInput: 1
|
embeddedLinuxEnableGamepadInput: 1
|
||||||
hmiLogStartupTiming: 0
|
hmiLogStartupTiming: 0
|
||||||
hmiCpuConfiguration:
|
hmiCpuConfiguration:
|
||||||
apiCompatibilityLevel: 6
|
apiCompatibilityLevel: 3
|
||||||
activeInputHandler: 2
|
activeInputHandler: 2
|
||||||
windowsGamepadBackendHint: 0
|
windowsGamepadBackendHint: 0
|
||||||
cloudProjectId:
|
cloudProjectId:
|
||||||
|
Loading…
Reference in New Issue
Block a user