浏览代码

Fix Physix implementation

/demo-work-customrenderer
André McGrail 5 年前
当前提交
2e7c3042
共有 6 个文件被更改,包括 126 次插入44 次删除
  1. 137
      Assets/Objects/boats/Prefabs/_Boat.prefab
  2. 12
      Assets/Scripts/Boat/AIcontroller.cs
  3. 3
      Assets/Scripts/Boat/Engine.cs
  4. 4
      Assets/Scripts/GameSystem/InputControls.cs
  5. 8
      Assets/Scripts/GameSystem/RaceManager.cs
  6. 6
      Assets/Scripts/GameSystem/WaypointGroup.cs

137
Assets/Objects/boats/Prefabs/_Boat.prefab


- component: {fileID: 4534809148113994}
- component: {fileID: 54710712322113256}
- component: {fileID: 64258884862185400}
- component: {fileID: 114559526544640098}
- component: {fileID: 114129291822198474}
- component: {fileID: 114571606569623246}
m_Layer: 11

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1553288845585282}
m_LocalRotation: {x: -0, y: -0.46607336, z: -0, w: 0.8847461}
m_LocalPosition: {x: -53.959473, y: 0.23000002, z: -56.539803}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4566539937980892}

- {fileID: 4674073439145674988}
m_LocalEulerAnglesHint: {x: 0, y: -55.559002, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!54 &54710712322113256
Rigidbody:
m_ObjectHideFlags: 0

serializedVersion: 2
m_Mass: 3200
m_Drag: 0.1
m_AngularDrag: 0.2
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 1

m_Convex: 1
m_CookingOptions: 14
m_Mesh: {fileID: 2899951614431091848, guid: a362db008c5274e03bf6f3d2387cf617, type: 3}
--- !u!114 &114559526544640098
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1553288845585282}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01c46922a8ed04b0081de10e51b3762f, type: 3}
m_Name:
m_EditorClassIdentifier:
vel: {x: 0, y: 0, z: 0}
engineSound: {fileID: 82633756123786494}
waterSound: {fileID: 82912682702107868}
torque: 5
horsePower: 18
enginePosition: {x: 0, y: 0.05, z: -3.31}
--- !u!114 &114129291822198474
MonoBehaviour:
m_ObjectHideFlags: 0

m_EditorClassIdentifier:
Human: 0
RandomizeColors: 1
PrimaryColor: {r: 0.6066833, g: 0.080696166, b: 0.8069615, a: 1}
TrimColor: {r: 0.15882511, g: 0.06897104, b: 0.19303852, a: 1}
PrimaryColor: {r: 0.09369812, g: 0.07329006, b: 0.7329004, a: 1}
TrimColor: {r: 0.26058555, g: 0.26709962, b: 0.056558255, a: 1}
engine: {fileID: 4530346687122435552}
cam: {fileID: 2365855355768168390}
--- !u!114 &114571606569623246
MonoBehaviour:
m_ObjectHideFlags: 0

m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!1 &725254494426090869
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4674073439145674988}
- component: {fileID: 6302303533833585893}
- component: {fileID: 7712310939893674192}
- component: {fileID: 4530346687122435552}
m_Layer: 0
m_Name: Boat_Interceptor_Engine
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4674073439145674988
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 725254494426090869}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.064, z: -3.3079998}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4534809148113994}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &6302303533833585893
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 725254494426090869}
m_Mesh: {fileID: 6235005220218627844, guid: a362db008c5274e03bf6f3d2387cf617, type: 3}
--- !u!23 &7712310939893674192
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 725254494426090869}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 99e41bed0266b42c2be534cc7d27de5a, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!114 &4530346687122435552
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 725254494426090869}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01c46922a8ed04b0081de10e51b3762f, type: 3}
m_Name:
m_EditorClassIdentifier:
RB: {fileID: 54710712322113256}
vel: {x: 0, y: 0, z: 0}
engineSound: {fileID: 82633756123786494}
waterSound: {fileID: 82912682702107868}
torque: 5
horsePower: 18
enginePosition: {x: 0, y: 0, z: -0.1}
--- !u!1 &3138619813684846845
GameObject:
m_ObjectHideFlags: 0

- m_Script
m_LockStageInInspector:
m_StreamingVersion: 20170927
m_Priority: 10
m_Priority: 20
m_StandbyUpdate: 0
m_LookAt: {fileID: 4534809148113994}
m_Follow: {fileID: 4534809148113994}

m_OnCameraLive:
m_PersistentCalls:
m_Calls: []
m_TypeName: Cinemachine.CinemachineBrain+VcamActivatedEvent, Cinemachine, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
m_LegacyBlendHint: 0
m_ComponentOwner: {fileID: 2704390242086546817}
--- !u!1 &8128372730392016786

12
Assets/Scripts/Boat/AIcontroller.cs


// Use this for initialization
void Start ()
{
float delay = WaypointGroup.Instance.raceDelay;
float delay = WaypointGroup.instance.raceDelay;
Invoke("GetNearestWP", delay);
}

void GetNearestWP()
{
WaypointGroup.Waypoint wp = WaypointGroup.Instance.GetClosestWaypoint(transform.position);
WaypointGroup.Waypoint wp = WaypointGroup.instance.GetClosestWaypoint(transform.position);
AssignWP(WaypointGroup.Instance.GetNextWaypoint(wp));
AssignWP(WaypointGroup.instance.GetNextWaypoint(wp));
//else
//AssignWP(WaypointGroup.Instance.GetClosestWaypoint(transform.position));
}

AssignWP(WaypointGroup.Instance.GetWaypoint(curWP));
AssignWP(WaypointGroup.instance.GetWaypoint(curWP));
}
void AssignWP(WaypointGroup.Waypoint wp)

curWP++;
if (curWP >= WaypointGroup.Instance.WPs.Count)
if (curWP >= WaypointGroup.instance.WPs.Count)
curWP = 0;
CalculatePath();
}

if (foundPath)
{
Gizmos.DrawLine(transform.position + (Vector3.up * 0.1f),
WaypointGroup.Instance.GetWaypoint(curWP).point);
WaypointGroup.instance.GetWaypoint(curWP).point);
Gizmos.DrawSphere(curWPPos, 1);
c = Color.red;

3
Assets/Scripts/Boat/Engine.cs


{
public class Engine : MonoBehaviour
{
private Rigidbody RB; // The rigid body attatched to the boat
public Rigidbody RB; // The rigid body attatched to the boat
public Vector3 vel; // Boats velocity
public AudioSource engineSound; // Engine sound clip

void Awake()
{
RB = gameObject.GetComponent<Rigidbody>(); // get the RB
engineSound.time = UnityEngine.Random.Range(0f, engineSound.clip.length); // randomly start the engine sound
waterSound.time = UnityEngine.Random.Range(0f, waterSound.clip.length); // randomly start the water sound

4
Assets/Scripts/GameSystem/InputControls.cs


// GENERATED AUTOMATICALLY FROM 'Assets/Data/New Controls.inputactions'
// GENERATED AUTOMATICALLY FROM 'Assets/Data/InputControls.inputactions'
using System.Collections;
using System.Collections.Generic;

public InputControls()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""New Controls"",
""name"": ""InputControls"",
""maps"": [
{
""name"": ""BoatControls"",

8
Assets/Scripts/GameSystem/RaceManager.cs


public Race raceData;
private void OnEnable()
private void Start()
WaypointGroup.Instance.reverse = raceData.reversed;
WaypointGroup.Instance.Setup();
WaypointGroup.instance.reverse = raceData.reversed;
WaypointGroup.instance.Setup();
CreateBoats();
}

foreach (var boat in raceData.boats)
{
var matrix = WaypointGroup.Instance.startingPositons[i];
var matrix = WaypointGroup.instance.startingPositons[i];
GameObject boatObject = Instantiate(boat.boatPrefab, matrix.GetColumn(3), Quaternion.LookRotation(matrix.GetColumn(2))) as GameObject;
boatObject.name = boat.boatName;

6
Assets/Scripts/GameSystem/WaypointGroup.cs


[Serializable]
public class WaypointGroup : MonoBehaviour
{
public static WaypointGroup Instance = null;
static WaypointGroup Instance = null;
public int WaypointGroupID = 0;
public Color WaypointColour = Color.yellow;
public bool Loop = false;

[SerializeField] public List<Waypoint> WPs = new List<Waypoint>();
private int curWpID;
public static WaypointGroup instance => Instance;
// Use this for initialization
void Awake()

public Matrix4x4[] GetStartPositions()
{
var position = WPs[0].point;
var position = WPs[0].point + Vector3.up;
var rotation = WPs[0].rotation;
if(reverse)
rotation *= Quaternion.AngleAxis(180f, Vector3.up);

正在加载...
取消
保存