Merge branch 'feature/world-test-prefabs' into dev
# Conflicts: # Assets/Player/Graphs/GrappleAimBT.asset # Assets/Player/Graphs/GroundedCheckBT.asset # Assets/Player/Graphs/PlayerLocomotionFSM.asset # Assets/Scenes/SampleScene.unity # Assets/Scripts/Core/Graph Tasks/ChangeAgentTransform.cs # Assets/Scripts/Core/Graph Tasks/ChangeCameraSettings.cs # Assets/Scripts/Core/Graph Tasks/ProcessMovement.cs # Assets/Scripts/Core/Graph Tasks/StartLaunchJump.cs # Assets/Scripts/Core/LockOnManager.cs
This commit is contained in:
49
Assets/Scripts/World/PlatformGenerator.cs
Normal file
49
Assets/Scripts/World/PlatformGenerator.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.ProBuilder;
|
||||
using UnityEngine.ProBuilder.MeshOperations;
|
||||
|
||||
public class PlatformGenerator : MonoBehaviour{
|
||||
public Vector2 sizeRange = new Vector2(5f, 20f);
|
||||
|
||||
public float snappingInterval = 2.5f;
|
||||
|
||||
void Start(){
|
||||
|
||||
}
|
||||
|
||||
[Button]
|
||||
void GenerateNewPlatform(int corners){
|
||||
ProBuilderMesh newShape = new GameObject().AddComponent<ProBuilderMesh>();
|
||||
|
||||
int originX = Mathf.RoundToInt(Random.Range(sizeRange.x, sizeRange.y));
|
||||
int originY = Mathf.RoundToInt(Random.Range(sizeRange.x, sizeRange.y));
|
||||
|
||||
originX = -Mathf.Abs(originX);
|
||||
originY = -Mathf.Abs(originY);
|
||||
|
||||
Vector3 origin = new Vector3(Snap(originX), 0f, Snap(originY));
|
||||
|
||||
Vector3[] points = new Vector3[corners];
|
||||
|
||||
for (int i = 0; i < corners; i++) {
|
||||
if (i == 0) {
|
||||
points[0] = origin;
|
||||
} else {
|
||||
points[i] = GetNewPoint(points[i - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 GetNewPoint(Vector3 previous){
|
||||
return Vector3.zero;
|
||||
|
||||
}
|
||||
|
||||
float Snap(float input){
|
||||
return ((input = snappingInterval / 2) / snappingInterval) * snappingInterval;
|
||||
}
|
||||
|
||||
newShape.CreateShapeFromPolygon(points, 5f, false);
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/World/PlatformGenerator.cs.meta
Normal file
2
Assets/Scripts/World/PlatformGenerator.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56af9443f43cafc40adcf591b83a78c7
|
||||
20
Assets/Scripts/World/SinMovement.cs
Normal file
20
Assets/Scripts/World/SinMovement.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SinMovement : MonoBehaviour{
|
||||
private float originalY;
|
||||
|
||||
public float speed;
|
||||
public float scale;
|
||||
|
||||
public float offset;
|
||||
|
||||
void Start(){
|
||||
originalY = transform.position.y;
|
||||
offset += Random.Range(-1, 1);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
transform.position = transform.position.Flatten(null, originalY + Mathf.Sin((Time.time + offset) * speed) * scale, null);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/World/SinMovement.cs.meta
Normal file
2
Assets/Scripts/World/SinMovement.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e33277577aa379a41a747f01aade9c96
|
||||
25
Assets/Scripts/World/SwayMovement.cs
Normal file
25
Assets/Scripts/World/SwayMovement.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SwayMovement : MonoBehaviour{
|
||||
Vector3 originalRot;
|
||||
public Vector3 swayAmount;
|
||||
public Vector3 swaySpeed;
|
||||
|
||||
private Vector3 offset;
|
||||
|
||||
void Start(){
|
||||
originalRot = transform.rotation.eulerAngles;
|
||||
offset = new Vector3(Random.Range(-5, 1), Random.Range(-1, 5), Random.Range(-3, 1));
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
Vector3 sway = new Vector3(
|
||||
originalRot.x + Mathf.Sin((Time.time + offset.x) * swaySpeed.x) * swayAmount.x,
|
||||
originalRot.y + Mathf.Sin((Time.time + offset.y) * swaySpeed.y) * swayAmount.y,
|
||||
originalRot.z + Mathf.Sin((Time.time + offset.z) * swaySpeed.z) * swayAmount.z
|
||||
);
|
||||
|
||||
transform.rotation = Quaternion.Euler(sway);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/World/SwayMovement.cs.meta
Normal file
2
Assets/Scripts/World/SwayMovement.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57870c7b66535c74688188df7e771ce7
|
||||
Reference in New Issue
Block a user