浏览代码

Small buoyant object tweaks, updated packages, removed analytics, no more debug conflicts with input

/demo-work
André McGrail 5 年前
当前提交
d5412042
共有 6 个文件被更改,包括 51 次插入44 次删除
  1. 27
      Assets/Scripts/GameSystem/AppSettings.cs
  2. 10
      Assets/scenes/Island.unity
  3. 36
      Packages/com.verasl.water-system/Scripts/BuoyantObject.cs
  4. 7
      Packages/manifest.json
  5. 11
      ProjectSettings/ProjectSettings.asset
  6. 4
      ProjectSettings/ProjectVersion.txt

27
Assets/Scripts/GameSystem/AppSettings.cs


using UnityEngine;
using System;
using UnityEngine;
using Object = System.Object;
namespace BoatAttack
{

public enum RenderRes
{
_Native,
_2440p,
_1440p,
_1080p,
_720p
}

private int qualityLevel;
// Use this for initialization
void Start()
void Awake()
{
Initialize();
SetRenderScale();

qualityVolume.profile = qualityVolumeProfiles[qualityLevel];
}
private void Start()
{
var obj = GameObject.Find("[Debug Updater]");
if(obj != null)
Destroy(obj);
}
void SetRenderScale()
{
float res;

res = 720f;
res = 1280f;
res = 1080f;
res = 1920f;
case RenderRes._2440p:
res = 2440f;
case RenderRes._1440p:
res = 2560f;
res = Camera.main.pixelHeight;
res = Camera.main.pixelWidth;
var renderScale = Mathf.Clamp(res / Camera.main.pixelHeight, 0.1f, 1.0f);
var renderScale = Mathf.Clamp(res / Camera.main.pixelWidth, 0.1f, 1.0f);
maxScale = renderScale;
UniversalRenderPipeline.asset.renderScale = renderScale;
}

10
Assets/scenes/Island.unity


m_Script: {fileID: 11500000, guid: ce2d6128fa5c04c7e84e7978ef8b37a4, type: 3}
m_Name:
m_EditorClassIdentifier:
useDOTS: 0
humanBoat: {fileID: 5912457028842276017, guid: ef588ca3a301a7c4b9fca4bdf9c1c390,
type: 3}
aiBoat: {fileID: 5602635442558840370, guid: f9d96a4051bc591428a153feeb5435ad, type: 3}
raceData:
boats:
- boatName: Boogie

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 471032674}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -81.25, y: -0.25, z: -31.25}
m_LocalPosition: {x: -62.5, y: -0.25, z: 56.25}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

- target: {fileID: 6589000190618102542, guid: e70416e3bc35d4004a9981d0ac102ba5,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.72625333
value: 0.7262534
value: 0.68427867
value: 0.6842787
objectReference: {fileID: 0}
- target: {fileID: 8115735017685696522, guid: e70416e3bc35d4004a9981d0ac102ba5,
type: 3}

36
Packages/com.verasl.water-system/Scripts/BuoyantObject.cs


private Vector3 localArchimedesForce;
[SerializeField]
private Vector3[] voxels; // voxel position
private Vector4[] voxels; // voxel position
private float3[] samplePoints; // sample points for height calc
private float3[] heights; // water height array(only size of 1 when simple or non-physical)
private float3[] normals; // water normal array(only used when non-physical and size of 1 also when simple)

if (_buoyancyType == BuoyancyType.NonPhysical || _buoyancyType == BuoyancyType.Physical)
{
voxels = new Vector3[1];
voxels = new Vector4[1];
voxels[0].w = 1f;
samplePoints = new float3[1];
}

{
//Debug.Log("new pass: " + gameObject.name);
Physics.autoSyncTransforms = false;
for(var i = 0; i < voxels.Length; i++) BuoyancyForce(voxels[i], heights[i].y, ref submergedAmount, ref debugInfo[i]);
Matrix4x4 transformMatrix = transform.localToWorldMatrix;
for(var i = 0; i < voxels.Length; i++) BuoyancyForce(transformMatrix * voxels[i], heights[i].y, ref submergedAmount, ref debugInfo[i]);
Physics.SyncTransforms();
Physics.autoSyncTransforms = true;
UpdateDrag(submergedAmount);

private void BuoyancyForce(Vector3 position, float waterHeight, ref float submergedAmount, ref DebugDrawing _debug)
{
var wp = transform.TransformPoint(position);
float waterLevel = waterHeight;
_debug.position = wp;
_debug.waterHeight = waterLevel;
_debug.force = Vector3.zero;
Vector3 force = Vector3.zero;
//_debug.position = position;
//_debug.waterHeight = waterHeight;
//_debug.force = Vector3.zero;
if (wp.y - voxelResolution < waterLevel)
if (position.y - voxelResolution < waterHeight)
float k = Mathf.Clamp01((waterLevel - (wp.y - voxelResolution)) / (voxelResolution * 2f));
float k = math.clamp((waterHeight - (position.y - voxelResolution)) / (voxelResolution * 2f), 0f, 1f);
submergedAmount += k / voxels.Length;//(math.clamp(waterLevel - (wp.y - voxelResolution), 0f, voxelResolution * 2f) / (voxelResolution * 2f)) / voxels.Count;
submergedAmount += k / voxels.Length;
var velocity = RB.GetPointVelocity(wp);
var velocity = RB.GetPointVelocity(position);
force = localDampingForce + Mathf.Sqrt(k) * localArchimedesForce;//\
RB.AddForceAtPosition(force, wp);
var force = localDampingForce + math.sqrt(k) * localArchimedesForce;
RB.AddForceAtPosition(force, position);
_debug.force = force; // For drawing force gizmos
//_debug.force = force; // For drawing force gizmos
//Debug.Log(string.Format("Position: {0:f1} -- Force: {1:f2} -- Height: {2:f2}\nVelocty: {3:f2} -- Damp: {4:f2} -- Mass: {5:f1} -- K: {6:f2}", wp, force, waterLevel, velocity, localDampingForce, RB.mass, localArchimedesForce));
}
}

transform.localScale = Vector3.one;
voxels = null;
var points = new List<Vector3>();
var points = new List<Vector4>();
var rawBounds = VoxelBounds();
voxelBounds = rawBounds;

}
}
if(inside)
points.Add(p);
points.Add(new Vector4(p.x, p.y, p.z, 1f));
}
}
}

7
Packages/manifest.json


{
"dependencies": {
"com.unity.2d.tilemap": "1.0.0",
"com.unity.analytics": "3.3.2",
"com.unity.inputsystem": "0.9.3-preview",
"com.unity.inputsystem": "0.9.6-preview",
"com.unity.test-framework": "1.0.17",
"com.unity.test-framework": "1.1.1",
"com.unity.timeline": "1.1.0",
"com.unity.timeline": "1.2.2",
"com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",

11
ProjectSettings/ProjectSettings.asset


--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 19
serializedVersion: 20
productGUID: b53215438aaf44a9f9817e608bbb159c
AndroidProfiler: 0
AndroidFilterTouchesWhenObscured: 0

xboxEnableFitness: 0
visibleInBackground: 1
allowFullscreenSwitch: 1
graphicsJobMode: 0
fullscreenMode: 1
xboxSpeechDB: 0
xboxEnableHeadOrientation: 0

sharedDepthBuffer: 0
dashSupport: 0
lowOverheadMode: 0
protectedContext: 0
v2Signing: 1
protectGraphicsMemory: 0
enableFrameTimingStats: 1
useHDRDisplay: 0
D3DHDRBitDepth: 0

m_GraphicsJobs: 0
- m_BuildTarget: WebGLSupport
m_GraphicsJobs: 0
m_BuildTargetGraphicsJobMode:
- m_BuildTarget: PS4Player
m_GraphicsJobMode: 0
- m_BuildTarget: XboxOnePlayer
m_GraphicsJobMode: 0
m_BuildTargetGraphicsAPIs:
- m_BuildTarget: iOSSupport
m_APIs: 10000000

4
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2019.3.0a12
m_EditorVersionWithRevision: 2019.3.0a12 (b073d123dd5d)
m_EditorVersion: 2019.3.0b2
m_EditorVersionWithRevision: 2019.3.0b2 (0c8fb71b3dfb)
正在加载...
取消
保存