Commit 56bedc08 authored by Max's avatar Max
Browse files

Added behaviour to flying platform and changed spore particle systems

parent 0ce36b9f
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1101 &-3204104958677283721
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: Breathing
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 4280757656030759606}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &-1368312593391732073
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Falling
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -3204104958677283721}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 8508eb2838e34d644aab5d09db9b2c8f, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &-378371908303915479
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 4280757656030759606}
m_Position: {x: 160, y: 80, z: 0}
- serializedVersion: 1
m_State: {fileID: -1368312593391732073}
m_Position: {x: 530, y: 80, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 800, y: 70, z: 0}
m_EntryPosition: {x: 180, y: 10, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 4280757656030759606}
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: FlyingPlatform
m_Name: FlyingPlatformAnimator
serializedVersion: 5
m_AnimatorParameters:
- m_Name: Breathing
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: -378371908303915479}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &4280757656030759606
AnimatorState:
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers: []
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Breathing
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 9195733496730187520}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: db047a5bff7b54f4eb266b150b408e0c, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &9195733496730187520
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Breathing
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -1368312593391732073}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
......@@ -12,6 +12,8 @@ GameObject:
- component: {fileID: 6241724066737184026}
- component: {fileID: 6241724066737184024}
- component: {fileID: 6241724066737184027}
- component: {fileID: 2660195609039020677}
- component: {fileID: 5226740682805395749}
m_Layer: 8
m_Name: Flying Platform
m_TagString: Untagged
......@@ -114,7 +116,7 @@ BoxCollider2D:
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_Offset: {x: 0, y: 0.25}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
......@@ -125,8 +127,51 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_Size: {x: 1, y: 0.5}
m_EdgeRadius: 0
--- !u!50 &2660195609039020677
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6241724066737184100}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 3
m_LinearDrag: 0.5
m_AngularDrag: 0.05
m_GravityScale: 0.1
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!114 &5226740682805395749
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6241724066737184100}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01f4d4cb97d99804c8d5c0bbf2113d0e, type: 3}
m_Name:
m_EditorClassIdentifier:
sporeBreathParticle: {fileID: 6241724066686691529}
rb: {fileID: 2660195609039020677}
animator: {fileID: 6241724066737184024}
speed: 1
breathingForce: 2
whatIsGround:
serializedVersion: 2
m_Bits: 256
maximumHeight: 4
minimumHeight: -4
--- !u!1001 &903980468320547485
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -147,7 +192,7 @@ PrefabInstance:
- target: {fileID: 6490983961685056081, guid: e42b5206757167a4eb0de34f54ab98ed,
type: 3}
propertyPath: m_LocalPosition.y
value: -1
value: -1.3
objectReference: {fileID: 0}
- target: {fileID: 6490983961685056081, guid: e42b5206757167a4eb0de34f54ab98ed,
type: 3}
......@@ -194,8 +239,34 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6490983961685056081, guid: e42b5206757167a4eb0de34f54ab98ed,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6490983961685056082, guid: e42b5206757167a4eb0de34f54ab98ed,
type: 3}
propertyPath: CollisionModule.multiplyColliderForceByParticleSize
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6490983961685056082, guid: e42b5206757167a4eb0de34f54ab98ed,
type: 3}
propertyPath: CollisionModule.collisionMode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6490983961685056082, guid: e42b5206757167a4eb0de34f54ab98ed,
type: 3}
propertyPath: CollisionModule.enabled
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e42b5206757167a4eb0de34f54ab98ed, type: 3}
--- !u!1 &6241724066686691529 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 6490983961685056084, guid: e42b5206757167a4eb0de34f54ab98ed,
type: 3}
m_PrefabInstance: {fileID: 903980468320547485}
m_PrefabAsset: {fileID: 0}
--- !u!4 &6241724066686691532 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6490983961685056081, guid: e42b5206757167a4eb0de34f54ab98ed,
......
......@@ -12,7 +12,7 @@ GameObject:
- component: {fileID: 3659447474157512488}
- component: {fileID: 3659447474157512489}
m_Layer: 0
m_Name: SporeExplode
m_Name: ExplodeParticles
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -1322,7 +1322,7 @@ ParticleSystem:
maxGradient:
serializedVersion: 2
key0: {r: 1, g: 0, b: 0.9652157, a: 0.78431374}
key1: {r: 0.35790887, g: 0.0025364957, b: 0.5377358, a: 0.5882353}
key1: {r: 0.35790887, g: 0.0025364957, b: 0.5377358, a: 0}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
......
......@@ -26,7 +26,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6490983961685056084}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -1, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
......@@ -284,7 +284,7 @@ ParticleSystem:
startSize:
serializedVersion: 2
minMaxState: 3
scalar: 1.5
scalar: 2.5
minScalar: 0.3
maxCurve:
serializedVersion: 2
......@@ -742,7 +742,7 @@ ParticleSystem:
m_TextureColorAffectsParticles: 1
m_TextureAlphaAffectsParticles: 1
m_TextureBilinearFiltering: 0
randomDirectionAmount: 0
randomDirectionAmount: 1
sphericalDirectionAmount: 0
randomPositionAmount: 0
radius:
......@@ -1322,7 +1322,7 @@ ParticleSystem:
maxGradient:
serializedVersion: 2
key0: {r: 1, g: 0, b: 0.9652157, a: 0.78431374}
key1: {r: 0.35790887, g: 0.0025364957, b: 0.5377358, a: 0.5882353}
key1: {r: 0.35790887, g: 0.0025364957, b: 0.5377358, a: 0}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
......@@ -1337,7 +1337,7 @@ ParticleSystem:
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime0: 39321
atime1: 65535
atime2: 0
atime3: 0
......@@ -3588,9 +3588,9 @@ ParticleSystem:
plane5: {fileID: 0}
m_Dampen:
serializedVersion: 2
minMaxState: 0
scalar: 0
minScalar: 0
minMaxState: 3
scalar: 0.5
minScalar: 0.1
maxCurve:
serializedVersion: 2
m_Curve:
......@@ -3641,9 +3641,9 @@ ParticleSystem:
m_RotationOrder: 4
m_Bounce:
serializedVersion: 2
minMaxState: 0
scalar: 1
minScalar: 1
minMaxState: 3
scalar: 0.5
minScalar: 0
maxCurve:
serializedVersion: 2
m_Curve:
......@@ -3694,9 +3694,9 @@ ParticleSystem:
m_RotationOrder: 4
m_EnergyLossOnCollision:
serializedVersion: 2
minMaxState: 0
scalar: 0
minScalar: 0
minMaxState: 3
scalar: 0.3
minScalar: 0.1
maxCurve:
serializedVersion: 2
m_Curve:
......
......@@ -1322,14 +1322,14 @@ ParticleSystem:
maxGradient:
serializedVersion: 2
key0: {r: 1, g: 0, b: 0.9652157, a: 0.78431374}
key1: {r: 0.35790887, g: 0.0025364957, b: 0.5377358, a: 0.5882353}
key1: {r: 0.35790887, g: 0.0025364957, b: 0.5377358, a: 0}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 32768
ctime0: 34117
ctime1: 65535
ctime2: 0
ctime3: 0
......@@ -1337,7 +1337,7 @@ ParticleSystem:
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime0: 55705
atime1: 65535
atime2: 0
atime3: 0
......
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlyingPlatformAI : MonoBehaviour
{
//Referenz auf den Spieler
private GameObject player;
//Referenzen auf den Gegner und Komponenten
private float myWidth;
private float myHeight;
public GameObject sporeBreathParticle;
public Rigidbody2D rb;
//Referenz auf den Animator
public Animator animator;
//horizontale Geschwindigkeit
public float speed;
//Kraft, mit welcher die Plattform vertikal steigt
public float breathingForce;
private Vector2 breathForce;
//alle Ebenen, mit denen der Gegner kollidieren soll
public LayerMask whatIsGround;
//obere und untere Grenze für die Aufenthaltszone der Plattform
public float maximumHeight;
public float minimumHeight;
//bool zum Schauen, ob Plattform steigt oder fällt
private bool breathing;
//bool zum Schauen, ob die Partikeleffekte den Status schon einmal verändert bekommen haben
private bool done;
// Start is called before the first frame update
void Start()
{
player = GameObject.FindGameObjectWithTag("Player");
SpriteRenderer sprite = GetComponent<SpriteRenderer>();
myWidth = sprite.bounds.extents.x;
myHeight = sprite.bounds.extents.y;
breathForce = new Vector2(0, breathingForce);
breathing = true;
done = false;
}
// Update is called once per frame
void Update()
{
Vector2 lineCastPositionRight = transform.position + transform.right * myWidth;
Vector2 right = new Vector2(transform.right.x, transform.right.y);
//wenn isBlocked nichts trifft, dann kann sich der Gegner noch bewegen
bool isBlocked = Physics2D.Linecast(lineCastPositionRight + right * 0.01f, lineCastPositionRight + right * 0.1f, whatIsGround);
//Visualisierung der linecasts mit Linien im Szene-Modus
Debug.DrawLine(lineCastPositionRight + right * 0.01f, lineCastPositionRight + right * 0.1f);
//schaut, ob Gegner sich noch bewegen kann
if (isBlocked)
{
//wechselt die Bewegungsrichtung
Vector3 currentRotation = transform.eulerAngles;
currentRotation.y += 180;
transform.eulerAngles = currentRotation;
}
//wenn ja
else
{
transform.position = Vector3.MoveTowards(transform.position, transform.position + transform.right, speed * Time.deltaTime);
}
if(breathing)
{
if (!done)
{
sporeBreathParticle.SetActive(true);
done = true;
}
Vector2 lineCastPositionUp = transform.position + transform.up * myHeight;
bool nearCeiling = Physics2D.Linecast(lineCastPositionUp + Vector2.up * 0.01f, lineCastPositionUp + Vector2.up * 1f, whatIsGround);
Debug.DrawLine(lineCastPositionUp + Vector2.up * 0.01f, lineCastPositionUp + Vector2.up * 1f);
if (transform.position.y > maximumHeight || nearCeiling)
{
breathing = false;
animator.SetBool("Breathing", false);
sporeBreathParticle.SetActive(false);
done = false;
}
rb.AddForce(breathForce);
}
else
{
if (!done)
{
sporeBreathParticle.SetActive(false);
done = true;
}
Vector2 lineCastPositionDown = transform.position - transform.up * myHeight;
bool nearGround = Physics2D.Linecast(lineCastPositionDown + Vector2.down * 0.01f, lineCastPositionDown + Vector2.down * 1f, whatIsGround);
Debug.DrawLine(lineCastPositionDown + Vector2.down * 0.01f, lineCastPositionDown + Vector2.down * 1f);
if (transform.position.y < minimumHeight || nearGround)
{
breathing = true;
animator.SetBool("Breathing", true);
sporeBreathParticle.SetActive(true);
done = false;
}
}
}
}
fileFormatVersion: 2
guid: 3399ba5f62dd4834fb345010f14da1ee
guid: 01f4d4cb97d99804c8d5c0bbf2113d0e
MonoImporter:
externalObjects: {}
serializedVersion: 2
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlyingPlatformIdleBehaviour : StateMachineBehaviour
{
//Referenz auf den Spieler
private GameObject player;
//Referenzen auf den Gegner
private Transform myTransform;
private Vector3 myPosition;
private float myWidth;
private float myHeight;
//horizontale Geschwindigkeit wenn nicht alarmiert
public float speed;
//alle Ebenen, mit denen der Gegner kollidieren soll
public LayerMask whatIsGround;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
player = GameObject.FindGameObjectWithTag("Player");
myTransform = animator.transform;
SpriteRenderer sprite = animator.GetComponent<SpriteRenderer>();
myWidth = sprite.bounds.extents.x;
myHeight = sprite.bounds.extents.y;
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Vector2 lineCastPosition = myTransform.position + myTransform.right * myWidth;
Vector2 right = new Vector2(myTransform.right.x, myTransform.right.y);
//wenn isBlocked nichts trifft, dann kann sich der Gegner noch bewegen
bool isBlocked = Physics2D.Linecast(lineCastPosition + right * 0.01f, lineCastPosition + right * 0.1f, whatIsGround);
//Visualisierung der linecasts mit Linien im Szene-Modus
Debug.DrawLine(lineCastPosition + right * 0.01f, lineCastPosition + right * 0.1f);
//schaut, ob Gegner sich noch bewegen kann
if (isBlocked)
{
//wechselt die Bewegungsrichtung
Vector3 currentRotation = myTransform.eulerAngles;
currentRotation.y += 180;
myTransform.eulerAngles = currentRotation;
}
//wenn ja
else
{
myTransform.position = Vector3.MoveTowards(myTransform.position, myTransform.position + myTransform.right, speed * Time.deltaTime);
}
}