Platform wiggelt

This commit is contained in:
DominikB 2023-06-27 18:39:27 +02:00
parent 6d18c44ff0
commit f3951918f3
6 changed files with 95 additions and 1 deletions

View File

@ -0,0 +1,39 @@
using UnityEngine;
public class Wiggler : MonoBehaviour
{
public float wiggleAmount = 1f; // Amount of wiggle (distance) from left to right
public float wiggleSpeed = 1f; // Speed of the wiggle
private Vector2 startPosition;
private float time;
public GameObject _LevelManager1;
private ButtonDOne script1;
private bool einsAn = false;
void Start()
{
startPosition = transform.position;
}
void Update()
{
script1 = _LevelManager1.GetComponent<ButtonDOne>();
einsAn = script1.einsAn;
if(einsAn){
// Calculate the horizontal position using a sine wave
float xPosition = startPosition.x + Mathf.Sin(time * wiggleSpeed) * wiggleAmount;
// Set the new position of the game object
transform.position = new Vector2(xPosition, transform.position.y);
// Increment the time variable based on the elapsed time
time += Time.deltaTime;}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 36fbcd880fbe94356ae4f9ee7a037a8b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3637,6 +3637,11 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 36f191eda52a886499b5b16518b8b85a, type: 3}
--- !u!1 &1330702969 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2968697922315996293, guid: dbd3b3a5517cb3e48b73ce0af4ad5f7b, type: 3}
m_PrefabInstance: {fileID: 1406162491}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1406162491
PrefabInstance:
m_ObjectHideFlags: 0
@ -3719,6 +3724,21 @@ Transform:
m_CorrespondingSourceObject: {fileID: 2968697922315996292, guid: dbd3b3a5517cb3e48b73ce0af4ad5f7b, type: 3}
m_PrefabInstance: {fileID: 1406162491}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1406162493
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1330702969}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 36fbcd880fbe94356ae4f9ee7a037a8b, type: 3}
m_Name:
m_EditorClassIdentifier:
wiggleAmount: 0.2
wiggleSpeed: 25
_LevelManager1: {fileID: 1583986083}
--- !u!1001 &1446124719
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -2521,7 +2521,7 @@ PrefabInstance:
objectReference: {fileID: 760890964}
- target: {fileID: 8316039429838813759, guid: 22badd0525f460b4d988841429f6a07e, type: 3}
propertyPath: ShiftingEnabled
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 22badd0525f460b4d988841429f6a07e, type: 3}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 13dab24be068f465aa5612166d56fdf6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
{
"MonoBehaviour": {
"Version": 4,
"EnableBurstCompilation": true,
"EnableOptimisations": true,
"EnableSafetyChecks": false,
"EnableDebugInAllBuilds": false,
"EnableArmv9SecurityFeatures": false,
"CpuMinTargetX32": 0,
"CpuMaxTargetX32": 0,
"CpuMinTargetX64": 0,
"CpuMaxTargetX64": 0,
"CpuTargetsX64": 72,
"OptimizeFor": 0
}
}