Browse Source

MAde push consistant

master
Joshua Reason 7 years ago
parent
commit
33da7c3282
6 changed files with 33 additions and 84 deletions
  1. +19
    -0
      IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs
  2. +1
    -1
      IronToad_UnityProject/Assets/Scripts/HeavyObject.cs
  3. +13
    -2
      IronToad_UnityProject/Assets/Scripts/WaterController.cs
  4. BIN
      IronToad_UnityProject/Assets/_Scenes/PhysicsTestScene.unity
  5. BIN
      IronToad_UnityProject/Assets/water/planeWater.FBX
  6. +0
    -81
      IronToad_UnityProject/Assets/water/planeWater.FBX.meta

+ 19
- 0
IronToad_UnityProject/Assets/Scripts/BuoyantObject.cs View File

@ -55,6 +55,25 @@ public class BuoyantObject : WaterObject {
// rb.drag = airDrag; // rb.drag = airDrag;
} }
public virtual IEnumerator pushObject(Vector3 point,float power, float totalTime) {
Vector3 dir = transform.position - point;
dir = Vector3.ProjectOnPlane(dir, Vector3.up);
dir.Normalize();
float elapsedTime = 0;
while (elapsedTime < totalTime) {
Vector3 force = dir * power * Time.deltaTime;
rb.AddForce(force);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

+ 1
- 1
IronToad_UnityProject/Assets/Scripts/HeavyObject.cs View File

@ -9,7 +9,7 @@ public abstract class HeavyObject : WaterObject {
public float splashPower; public float splashPower;
public override void OnWaterEnter(WaterController water) { public override void OnWaterEnter(WaterController water) {
water.CreateWave(transform.position,splashRadius,splashPower)
water.CreateWave(transform.position, splashRadius, splashPower);
} }
} }

+ 13
- 2
IronToad_UnityProject/Assets/Scripts/WaterController.cs View File

@ -37,14 +37,25 @@ public class WaterController : MonoBehaviour {
/// <param name="point"> point where water is createds</param> /// <param name="point"> point where water is createds</param>
/// <param name="radius"> radius of effected object</param> /// <param name="radius"> radius of effected object</param>
/// <param name="power"> power with chich the objects are pushed</param> /// <param name="power"> power with chich the objects are pushed</param>
public void CreateWave(Vector3 point, float radius, float power){
public void CreateWave(Vector3 point, float radius, float power) {
//find all colliders within the wave distance //find all colliders within the wave distance
point.y = transform.position.y; point.y = transform.position.y;
StartCoroutine(waveController(point, radius, power, 2));
Collider[] colliders = Physics.OverlapSphere(point, radius);
foreach (Collider hit in colliders) {
Debug.Log(hit.name);
BuoyantObject hitScript = hit.gameObject.GetComponent<BuoyantObject>();
if (hitScript != null) {
Debug.DrawLine(point, hit.transform.position, Color.blue, 1);
StartCoroutine(hitScript.pushObject(point, power, 2));
}
//StartCoroutine(waveController(point, radius, power, 2));
}
} }
#endregion Interaction Functions #endregion Interaction Functions

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


BIN
IronToad_UnityProject/Assets/water/planeWater.FBX View File


+ 0
- 81
IronToad_UnityProject/Assets/water/planeWater.FBX.meta View File

@ -1,81 +0,0 @@
fileFormatVersion: 2
guid: bd1854f4908ffa544b88d16ba58fcbc6
timeCreated: 1484985428
licenseType: Pro
ModelImporter:
serializedVersion: 19
fileIDToRecycleName:
100000: //RootNode
400000: //RootNode
2300000: //RootNode
3300000: //RootNode
4300000: Plane001
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: 1
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:

Loading…
Cancel
Save