ATC522-011\IGDA 8 years ago
parent
commit
e998f810b5
28 changed files with 463 additions and 44 deletions
  1. +9
    -0
      IronToad_UnityProject/Assets/Animations.meta
  2. +9
    -0
      IronToad_UnityProject/Assets/Models.meta
  3. BIN
      IronToad_UnityProject/Assets/Models/M_Boat.FBX
  4. +81
    -0
      IronToad_UnityProject/Assets/Models/M_Boat.FBX.meta
  5. +9
    -0
      IronToad_UnityProject/Assets/Models/Materials.meta
  6. BIN
      IronToad_UnityProject/Assets/Models/Materials/No Name.mat
  7. +8
    -0
      IronToad_UnityProject/Assets/Models/Materials/No Name.mat.meta
  8. +9
    -0
      IronToad_UnityProject/Assets/Physics Materials.meta
  9. BIN
      IronToad_UnityProject/Assets/Physics Materials/Water.physicMaterial
  10. +8
    -0
      IronToad_UnityProject/Assets/Physics Materials/Water.physicMaterial.meta
  11. +9
    -0
      IronToad_UnityProject/Assets/Prefabs.meta
  12. BIN
      IronToad_UnityProject/Assets/Prefabs/Boat.prefab
  13. +8
    -0
      IronToad_UnityProject/Assets/Prefabs/Boat.prefab.meta
  14. BIN
      IronToad_UnityProject/Assets/Prefabs/Crate.prefab
  15. +8
    -0
      IronToad_UnityProject/Assets/Prefabs/Crate.prefab.meta
  16. +13
    -16
      IronToad_UnityProject/Assets/Scripts/BoatController.cs
  17. +24
    -8
      IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs
  18. +27
    -7
      IronToad_UnityProject/Assets/Scripts/PlayerController.cs
  19. +59
    -10
      IronToad_UnityProject/Assets/Scripts/WaterController.cs
  20. +3
    -3
      IronToad_UnityProject/Assets/Scripts/WaterObject.cs
  21. +9
    -0
      IronToad_UnityProject/Assets/Shaders.meta
  22. +125
    -0
      IronToad_UnityProject/Assets/Shaders/TwoToneDiffuse.shader
  23. +9
    -0
      IronToad_UnityProject/Assets/Shaders/TwoToneDiffuse.shader.meta
  24. +9
    -0
      IronToad_UnityProject/Assets/Sound.meta
  25. +9
    -0
      IronToad_UnityProject/Assets/Sound/Music.meta
  26. +9
    -0
      IronToad_UnityProject/Assets/Sound/SFX.meta
  27. +9
    -0
      IronToad_UnityProject/Assets/Textures.meta
  28. BIN
      IronToad_UnityProject/Assets/_Scenes/PhysicsTestScene.unity

+ 9
- 0
IronToad_UnityProject/Assets/Animations.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 653e5549e4b277c4facae79f936bb3e6
folderAsset: yes
timeCreated: 1484972317
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Models.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9439645a6c5c6dc4391460bf243d99a9
folderAsset: yes
timeCreated: 1484972317
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
IronToad_UnityProject/Assets/Models/M_Boat.FBX View File


+ 81
- 0
IronToad_UnityProject/Assets/Models/M_Boat.FBX.meta View File

@ -0,0 +1,81 @@
fileFormatVersion: 2
guid: 6d2ec77f0914eaa43bb1284587d7d234
timeCreated: 1484955399
licenseType: Free
ModelImporter:
serializedVersion: 19
fileIDToRecycleName:
100000: //RootNode
400000: //RootNode
2300000: //RootNode
3300000: //RootNode
4300000: boat
9500000: //RootNode
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: 0.2
meshCompression: 0
addColliders: 0
importBlendShapes: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
keepQuads: 0
weldVertices: 1
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
importAnimation: 1
copyAvatar: 0
humanDescription:
serializedVersion: 2
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
rootMotionBoneName:
rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1}
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 2
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Models/Materials.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 09e8828582845e14eaff20477097a3a9
folderAsset: yes
timeCreated: 1484955399
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
IronToad_UnityProject/Assets/Models/Materials/No Name.mat View File


+ 8
- 0
IronToad_UnityProject/Assets/Models/Materials/No Name.mat.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 90392ab8faa788c4198badcacd62f103
timeCreated: 1484955399
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Physics Materials.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5448b4db62ef7a84db1e026d5a0ab9f7
folderAsset: yes
timeCreated: 1484954738
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
IronToad_UnityProject/Assets/Physics Materials/Water.physicMaterial View File


+ 8
- 0
IronToad_UnityProject/Assets/Physics Materials/Water.physicMaterial.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7306b2bc1a4eb1848aaec35e00857c19
timeCreated: 1484954750
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Prefabs.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9b86a2ac850130a4aadb3c416f7faa43
folderAsset: yes
timeCreated: 1484955477
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
IronToad_UnityProject/Assets/Prefabs/Boat.prefab View File


+ 8
- 0
IronToad_UnityProject/Assets/Prefabs/Boat.prefab.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c8aa714f1d5073f43b7d42f73289d5df
timeCreated: 1484957074
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
IronToad_UnityProject/Assets/Prefabs/Crate.prefab View File


+ 8
- 0
IronToad_UnityProject/Assets/Prefabs/Crate.prefab.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b708e82a945ea904cb0b2ae0db8244fc
timeCreated: 1484957112
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 13
- 16
IronToad_UnityProject/Assets/Scripts/BoatController.cs View File

@ -3,19 +3,9 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoatController : WaterObject {
public class BoatController : BuoyantObject {
public override void OnWaterEnter() {
throw new NotImplementedException();
}
public override void OnWaterStay() {
throw new NotImplementedException();
}
public override void OnWaterExit() {
throw new NotImplementedException();
}
public float trunSpeed = 0.5f;
// Use this for initialization
@ -23,8 +13,15 @@ public class BoatController : WaterObject {
}
// Update is called once per frame
void Update () {
}
void Update() {
lookAtDir(Vector3.ProjectOnPlane(rb.velocity, Vector3.up));
}
// Update is called once per frame
void lookAtDir(Vector3 inputDir) {
Quaternion targetRotation = Quaternion.LookRotation(inputDir,Vector3.up);
float str = Mathf.Min(trunSpeed * Time.deltaTime, 1);
transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, str);
}
}

+ 24
- 8
IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs View File

@ -10,33 +10,49 @@ public class BuoyantObject : WaterObject {
[Tooltip ("How fast object will raise into the ")]
public float BouancyValue = 5;
[Tooltip ("Local point, at which the object floats within the water")]
public Vector3 BouancyPoint = Vector3.zero;
//rigidbody attached to GameObject
private Rigidbody rb;
protected Rigidbody rb;
private float airDrag;
#region Unity Functions
void Awake() {
rb = GetComponent<Rigidbody>();
airDrag = rb.drag;
}
#endregion Unity Functions
#endregion Unity Functions
public override void OnWaterStay(GameObject water,float waveHeight) {
Vector3 waterEntryPoint = transform.position;
waterEntryPoint.y = water.transform.position.y + waveHeight;
public override void OnWaterStay() {
float distance = Vector3.Distance(transform.position + (BouancyPoint * transform.lossyScale.magnitude) , waterEntryPoint);
Vector3 force = Vector3.up * BouancyValue * Mathf.Pow(distance,1.5f);
if (waterEntryPoint.y < gameObject.transform.position.y + (BouancyPoint.y * transform.lossyScale.y))
force = Vector3.zero;
rb.AddForce(force);
Vector3 dragVel = rb.velocity;
dragVel.y *= 0.98f;
rb.velocity = dragVel;
}
public override void OnWaterEnter() {
throw new NotImplementedException();
public override void OnWaterEnter(GameObject water) {
//rb.drag = 1;
}
public override void OnWaterExit() {
throw new NotImplementedException();
public override void OnWaterExit(GameObject water) {
// rb.drag = airDrag;
}
/// <summary>

+ 27
- 7
IronToad_UnityProject/Assets/Scripts/PlayerController.cs View File

@ -4,13 +4,33 @@ using UnityEngine;
public class PlayerController : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
if (Input.GetButtonDown("Fire1")) {
Debug.Log("Click");
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
LayerMask rayMask = (1 << 4);
Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);
if (Physics.Raycast(ray, out hit, Mathf.Infinity,rayMask)) {
WaterController waterScript = hit.collider.gameObject.GetComponent<WaterController>();
Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red,1);
Debug.Log("I hit: " + hit.transform.name);
if (waterScript != null)
waterScript.CreateWave(hit.point, 10, 5);
}
}
}
}

+ 59
- 10
IronToad_UnityProject/Assets/Scripts/WaterController.cs View File

@ -4,6 +4,16 @@ using UnityEngine;
public class WaterController : MonoBehaviour {
public AnimationCurve RipplePower;
private float waveOffset = 0;
public float waveScale = 1;
public float waterWidth = 1;
public float waveSpeed = 1;
public float maxWaveHeight = 2;
#region Unity Functions
// Use this for initialization
void Start() {
@ -13,6 +23,8 @@ public class WaterController : MonoBehaviour {
// Update is called once per frame
void Update() {
waveOffset += 0.1f *waveSpeed * Time.deltaTime;
}
#endregion Unity Fucntions
@ -28,25 +40,56 @@ public class WaterController : MonoBehaviour {
public void CreateWave(Vector3 point, float radius, float power){
//find all colliders within the wave distance
Collider[] colliders = Physics.OverlapSphere(point, radius);
foreach (Collider hit in colliders) {
Rigidbody rb = hit.GetComponent<Rigidbody>();
StartCoroutine(waveController(point, radius, power, 2));
if (rb != null)
rb.AddExplosionForce(power, point, radius, 0.0f);
}
}
#endregion Interaction Functions
#region Helper Functions
public IEnumerator waveController (Vector3 point, float radius, float power, float rippleTime) {
float elapsedTime = 0.0f;
while (elapsedTime < rippleTime) {
float curRippleForce = RipplePower.Evaluate(elapsedTime / rippleTime);
#endregion Interaction Functions
Collider[] colliders = Physics.OverlapSphere(point, radius);
foreach (Collider hit in colliders) {
Rigidbody rb = hit.GetComponent<Rigidbody>();
Debug.DrawLine(point, hit.transform.position, Color.blue, 1);
if (rb != null) {
Debug.DrawLine(point, hit.transform.position, Color.blue, 1);
Vector3 flatPoint = new Vector3(point.x, hit.transform.position.y, point.z);
rb.AddExplosionForce(power * curRippleForce, point, radius, 0.0f);
}
}
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
}
#endregion Helper Functions
#region Collision Functions
void OnTriggerEnter(Collider other) {
//calls appropriate function if the object should interact with the water on enter
WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>();
if (waterInteraction != null) {
waterInteraction.OnWaterEnter();
waterInteraction.OnWaterEnter(gameObject);
}
}
@ -56,7 +99,13 @@ public class WaterController : MonoBehaviour {
//calls appropriate function if the object should interact with the water on stay
WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>();
if (waterInteraction != null) {
waterInteraction.OnWaterStay();
Vector2 waveCoords = new Vector2(other.transform.position.x, other.transform.position.z);
waveCoords = waveCoords / waterWidth * waveScale;
float waveHeight = Mathf.PerlinNoise(waveCoords.x, waveCoords.y + waveOffset);
waterInteraction.OnWaterStay(gameObject,waveHeight * maxWaveHeight);
}
}
@ -65,7 +114,7 @@ public class WaterController : MonoBehaviour {
//calls appropriate function if the object should interact with the water on exit
WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>();
if (waterInteraction != null) {
waterInteraction.OnWaterExit();
waterInteraction.OnWaterExit(gameObject);
}
}

+ 3
- 3
IronToad_UnityProject/Assets/Scripts/WaterObject.cs View File

@ -7,17 +7,17 @@ public abstract class WaterObject : MonoBehaviour {
/// <summary>
/// Called when object intersects water plane
/// </summary>
public abstract void OnWaterEnter();
public abstract void OnWaterEnter(GameObject water);
/// <summary>
/// Called while objects stays in water
/// </summary>
public abstract void OnWaterStay();
public abstract void OnWaterStay(GameObject water,float waveHeight);
/// <summary>
/// Called when object leaves water
/// </summary>
public abstract void OnWaterExit();
public abstract void OnWaterExit(GameObject water);
}

+ 9
- 0
IronToad_UnityProject/Assets/Shaders.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: bfbf638121c6c304da5c93c85a196a42
folderAsset: yes
timeCreated: 1484972473
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 125
- 0
IronToad_UnityProject/Assets/Shaders/TwoToneDiffuse.shader
File diff suppressed because it is too large
View File


+ 9
- 0
IronToad_UnityProject/Assets/Shaders/TwoToneDiffuse.shader.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5a54ffaff2b76814ca8e6209d7912ba2
timeCreated: 1484972480
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Sound.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 091049497d8a5784f93123e69e2329d6
folderAsset: yes
timeCreated: 1484972317
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Sound/Music.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1715d56e0d2b68246a82993db31014ab
folderAsset: yes
timeCreated: 1484972317
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Sound/SFX.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: de5a3adcedb96f64183518ac89622ade
folderAsset: yes
timeCreated: 1484972317
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Textures.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2a6e699820a38a544acfc0015eb679a2
folderAsset: yes
timeCreated: 1484972317
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
IronToad_UnityProject/Assets/_Scenes/PhysicsTestScene.unity View File


Loading…
Cancel
Save