浏览代码
Assorted changes
Assorted changes
- Added buoy manager to lower cost of buoys - One particle system for all buoys - Added windsurfer manager to lower cost of windsurfers - Added level bound colliders - fixed GC alloc on boat buoyantobject/demo-work
André McGrail
5 年前
当前提交
64853ed9
共有 18 个文件被更改,包括 2585 次插入 和 1314 次删除
-
104Assets/Objects/Levels/Island/Dynamic Objects.prefab
-
992Assets/Objects/Levels/Island/Environment Objects Prefabs/Props_Floating.prefab
-
70Assets/Objects/Levels/Island/Environment Objects.prefab
-
9Assets/Objects/Levels/Island/Island Level.prefab
-
166Assets/Objects/Levels/Island/Logic.prefab
-
311Assets/Objects/props/props/Prefabs/Arrow.prefab
-
992Assets/Objects/props/props/Prefabs/Buoy.prefab
-
39Assets/Objects/props/props/Prefabs/Windsurfer.prefab
-
14Assets/Scripts/Boat/Engine.cs
-
37Assets/Scripts/Environment/BuoyManager.cs
-
2Assets/Scripts/Environment/WindsurferManager.cs.meta
-
992Assets/scenes/Island.unity
-
30Packages/com.verasl.water-system/Scripts/BuoyantObject.cs
-
2Packages/com.verasl.water-system/Scripts/GerstnerWavesJobs.cs
-
34Packages/com.verasl.water-system/Scripts/LocalToWorldJob.cs
-
63Assets/Scripts/Environment/WindsurferManager.cs
-
42Assets/Scripts/Environment/WindsurferLogic.cs
-
0/Assets/Scripts/Environment/WindsurferManager.cs.meta
992
Assets/Objects/Levels/Island/Environment Objects Prefabs/Props_Floating.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
992
Assets/Objects/props/props/Prefabs/Buoy.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
992
Assets/scenes/Island.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System; |
|||
using UnityEngine; |
|||
using WaterSystem; |
|||
using Unity.Mathematics; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using Unity.Collections; |
|||
|
|||
namespace BoatAttack |
|||
{ |
|||
/// <summary>
|
|||
/// This controls the logic for the wind surfer
|
|||
/// </summary>
|
|||
public class WindsurferManager : MonoBehaviour |
|||
{ |
|||
public Transform[] surfers; |
|||
private NativeArray<float3> points; // point to sample wave height
|
|||
private float3[] heights; // height sameple from water system
|
|||
private float3[] normals; // height sameple from water system
|
|||
private Vector3[] smoothPositions; // the smoothed position
|
|||
private int _guid; // the objects GUID for wave height lookup
|
|||
|
|||
// Use this for initialization
|
|||
void Start() |
|||
{ |
|||
_guid = gameObject.GetInstanceID(); |
|||
|
|||
heights = new float3[surfers.Length]; |
|||
normals = new float3[surfers.Length]; |
|||
smoothPositions = new Vector3[surfers.Length]; |
|||
|
|||
for (int i = 0; i < surfers.Length; i++) |
|||
{ |
|||
smoothPositions[i] = surfers[i].position; |
|||
} |
|||
points = new NativeArray<float3>(surfers.Length, Allocator.Persistent); |
|||
} |
|||
|
|||
private void OnDisable() |
|||
{ |
|||
points.Dispose(); |
|||
} |
|||
|
|||
// Update is called once per frame - TODO - need to validate logic here (not smooth at all in demo)
|
|||
void Update() |
|||
{ |
|||
GerstnerWavesJobs.UpdateSamplePoints(ref points, _guid); |
|||
GerstnerWavesJobs.GetData(_guid, ref heights, ref normals); |
|||
|
|||
for (int i = 0; i < surfers.Length; i++) |
|||
{ |
|||
smoothPositions[i] = surfers[i].position; |
|||
// Sample the water height at the current position
|
|||
points[0] = smoothPositions[i]; |
|||
if (heights[0].y > smoothPositions[i].y) |
|||
smoothPositions[i].y += Time.deltaTime; |
|||
else |
|||
smoothPositions[i].y -= Time.deltaTime * 0.25f; |
|||
surfers[i].position = smoothPositions[i]; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using WaterSystem; |
|||
using Unity.Mathematics; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace BoatAttack |
|||
{ |
|||
/// <summary>
|
|||
/// This controls the logic for the wind surfer
|
|||
/// </summary>
|
|||
public class WindsurferLogic : MonoBehaviour |
|||
{ |
|||
private float3[] point = new float3[1]; // point to sample wave height
|
|||
private float3[] heights = new float3[1]; // height sameple from water system
|
|||
private float3[] normals = new float3[1]; // height sameple from water system
|
|||
private Vector3 smoothPosition; // the smoothed position
|
|||
private int _guid; // the objects GUID for wave height lookup
|
|||
|
|||
// Use this for initialization
|
|||
void Start() |
|||
{ |
|||
_guid = gameObject.GetInstanceID(); |
|||
smoothPosition = transform.position; |
|||
} |
|||
|
|||
// Update is called once per frame - TODO - need to validate logic here (not smooth at all in demo)
|
|||
void Update() |
|||
{ |
|||
smoothPosition = transform.position; |
|||
// Sample the water height at the current position
|
|||
point[0] = transform.position; |
|||
GerstnerWavesJobs.UpdateSamplePoints(point, _guid); |
|||
GerstnerWavesJobs.GetData(_guid, ref heights, ref normals); |
|||
if (heights[0].y > smoothPosition.y) |
|||
smoothPosition.y += Time.deltaTime; |
|||
else |
|||
smoothPosition.y -= Time.deltaTime * 0.25f; |
|||
transform.position = smoothPosition; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue