Cleaned up the script so it now works independant of gravity. Added a second Mover script that controls the speed and direction the boulder moves once triggered. Added a target to the prefab as this is the point at which the boulder moves towards.
This commit is contained in:
parent
1b02a15353
commit
b0b5c09c54
|
@ -1,5 +1,100 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1157356545022895102
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3284889540147964939}
|
||||
- component: {fileID: 1767268791732459175}
|
||||
- component: {fileID: 6231901549469343104}
|
||||
- component: {fileID: 6896559390184638598}
|
||||
m_Layer: 0
|
||||
m_Name: Target
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &3284889540147964939
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1157356545022895102}
|
||||
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: []
|
||||
m_Father: {fileID: 6536764240838670284}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &1767268791732459175
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1157356545022895102}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &6231901549469343104
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1157356545022895102}
|
||||
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_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, 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
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!65 &6896559390184638598
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1157356545022895102}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &6536764240838670287
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -29,6 +124,7 @@ Transform:
|
|||
m_Children:
|
||||
- {fileID: 6536764241329740425}
|
||||
- {fileID: 6536764242362416353}
|
||||
- {fileID: 3284889540147964939}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
|
@ -253,6 +253,34 @@ PrefabInstance:
|
|||
m_Modification:
|
||||
m_TransformParent: {fileID: 1571618361}
|
||||
m_Modifications:
|
||||
- target: {fileID: 3284889540147964939, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3284889540147964939, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_LocalScale.y
|
||||
value: 0.1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3284889540147964939, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_LocalScale.z
|
||||
value: 0.1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3284889540147964939, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 18.726
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3284889540147964939, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -0.718
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3284889540147964939, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.238
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6231901549469343104, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6536764240838670284, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 2
|
||||
|
@ -301,6 +329,18 @@ PrefabInstance:
|
|||
propertyPath: m_Name
|
||||
value: RollingBoulder
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6536764242362416359, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: speed
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6536764242362416359, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: target
|
||||
value:
|
||||
objectReference: {fileID: 478980238}
|
||||
- target: {fileID: 6536764242362416359, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
--- !u!1 &52807941 stripped
|
||||
|
@ -1051,6 +1091,25 @@ Transform:
|
|||
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: e20114b5c13a067488940c5cc8e13b60, type: 3}
|
||||
m_PrefabInstance: {fileID: 3060674077756111689}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &325333170 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6536764242362416381, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
m_PrefabInstance: {fileID: 51159030}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &325333178
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 325333170}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 364f9139f6e39a244a53d33f7eca4c65, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
speed: 2
|
||||
target: {fileID: 478980238}
|
||||
--- !u!1 &332132158 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: f73d020fede261d4bac919488c8a778d, type: 3}
|
||||
|
@ -1415,6 +1474,11 @@ Transform:
|
|||
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: ef7a51de2c5c5c5438ce6fea733533b2, type: 3}
|
||||
m_PrefabInstance: {fileID: 3060674077686378536}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &478980238 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 1157356545022895102, guid: baf177258b70ed448964e62915be41ee, type: 3}
|
||||
m_PrefabInstance: {fileID: 51159030}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &480152489 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 3ea432459c1408040880f4c027fab559, type: 3}
|
||||
|
@ -2349,7 +2413,7 @@ PrefabInstance:
|
|||
m_Modifications:
|
||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0.000000005587936
|
||||
value: -0.000000011175871
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
|
@ -2357,23 +2421,23 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0.001504234
|
||||
value: -0.001504235
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.9979446
|
||||
value: 0.9979251
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.018160641
|
||||
value: -0.018160317
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0.061445504
|
||||
value: 0.061761502
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0.001118188
|
||||
value: 0.0011239406
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_Name
|
||||
|
@ -2425,47 +2489,47 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
value: 0.021596579
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
value: 0.73940504
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
value: -0.30432126
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.99914503
|
||||
value: 0.9791332
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0.000000005587936
|
||||
value: 0.19930515
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0.041315872
|
||||
value: -0.039160818
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0.001504234
|
||||
value: 0.0064973626
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.9995819
|
||||
value: 0.9995727
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0.000000007450581
|
||||
value: -0.000000016763806
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0.028896395
|
||||
value: 0.029212706
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0.001052064
|
||||
value: 0.0010635803
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9122906920607805875, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Mover : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float speed;
|
||||
[SerializeField] private GameObject target;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
//transform.LookAt(player.transform);
|
||||
Quaternion targetRotation = Quaternion.LookRotation(target.transform.position - transform.position);
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 1 * Time.deltaTime);
|
||||
transform.position += transform.forward * speed * Time.deltaTime;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 364f9139f6e39a244a53d33f7eca4c65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -5,12 +5,10 @@ using UnityEngine;
|
|||
public class RollingBoulder : MonoBehaviour
|
||||
{
|
||||
Rigidbody rb;
|
||||
// Float for speed of the arrow.
|
||||
[SerializeField] private float speed;
|
||||
// Float for time in seconds to wait to destroy the arrow on contact with any other gameobject that is no the player.
|
||||
[SerializeField] private float waitToDestroy;
|
||||
// Vector3 to set direction of travel for the arrow once the trigger is activated.
|
||||
//[SerializeField] private Vector3 direction;
|
||||
|
||||
public GameObject target;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
@ -22,7 +20,9 @@ public class RollingBoulder : MonoBehaviour
|
|||
// Checks to make sure other collider is the Player using tag.
|
||||
if (other.gameObject.CompareTag("Player"))
|
||||
{
|
||||
rb.useGravity = true;
|
||||
Mover mover =
|
||||
gameObject.GetComponent<Mover>();
|
||||
mover.enabled = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue