Szene 2
This commit is contained in:
parent
46955bbec4
commit
4d9b55b296
4 changed files with 259 additions and 15 deletions
102
Assets/AblaufKleinerStern2.cs
Normal file
102
Assets/AblaufKleinerStern2.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
public class AblaufKleinerStern2 : MonoBehaviour
|
||||
{
|
||||
public GameObject kleinerStern;
|
||||
public GameObject hase;
|
||||
public GameObject globalLight;
|
||||
|
||||
private Action nextStep;
|
||||
private class Task {
|
||||
private Action action;
|
||||
private float time;
|
||||
|
||||
public Task(Action action, float time){
|
||||
this.action = action;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public bool isDue(){
|
||||
return Time.time >= time;
|
||||
}
|
||||
|
||||
public void Do(){
|
||||
action();
|
||||
}
|
||||
}
|
||||
private List<Task> taskList;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
nextStep = SternFaellt;
|
||||
taskList = new List<Task>();
|
||||
kleinerStern.GetComponent<Rigidbody2D>().simulated = false;
|
||||
hase.GetComponent<Rigidbody2D>().simulated = false;
|
||||
globalLight.GetComponent<Light2D>().intensity = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
List<Task> newlist = new();
|
||||
foreach (Task t in taskList){
|
||||
if (t.isDue()){
|
||||
t.Do();
|
||||
} else {
|
||||
newlist.Add(t);
|
||||
}
|
||||
}
|
||||
taskList = newlist;
|
||||
if (Input.GetKeyDown(KeyCode.Space)){
|
||||
nextStep();
|
||||
}
|
||||
}
|
||||
|
||||
private void SternFaellt(){
|
||||
globalLight.GetComponent<Lichtsteuerung>().FadeToIntensity(1, .3f);
|
||||
Rigidbody2D sternRigBod = kleinerStern.GetComponent<Rigidbody2D>();
|
||||
sternRigBod.simulated = true;
|
||||
kleinerStern.transform.position = new Vector2(-0.8f, 6.0f);
|
||||
hase.transform.position = new Vector2(11, -4);
|
||||
hase.GetComponent<HaseBewegung>().Turn();
|
||||
scheduleNewTask(2.5f, delegate(){
|
||||
sternRigBod.simulated = false;
|
||||
SternBewegung sternBewegung = kleinerStern.GetComponent<SternBewegung>();
|
||||
sternBewegung.enabled = true;
|
||||
sternBewegung.GoToPositionWithVelocity(new Vector2(-2.1f, -2.6f), 1);
|
||||
hase.GetComponent<Rigidbody2D>().simulated = true;
|
||||
});
|
||||
nextStep = AuftrittHase;
|
||||
}
|
||||
|
||||
private void AuftrittHase(){
|
||||
hase.GetComponent<HaseBewegung>().GoToXPosition(2.0f);
|
||||
nextStep = Abgang;
|
||||
}
|
||||
|
||||
private void Abgang(){
|
||||
HaseBewegung haseBewegung = hase.GetComponent<HaseBewegung>();
|
||||
haseBewegung.GoToXPosition(15);
|
||||
haseBewegung.Turn();
|
||||
SternBewegung sternBewegung = kleinerStern.GetComponent<SternBewegung>();
|
||||
sternBewegung.GoToPositionWithVelocity(new Vector2(12, 0), haseBewegung.jumpVelocityX * .8f);
|
||||
sternBewegung.randomnessIntensity = 1;
|
||||
sternBewegung.randomnessBaseAngle = 5;
|
||||
sternBewegung.randomMovementDuration = .6f;
|
||||
sternBewegung.wobblingAngle = 10;
|
||||
sternBewegung.wobblingDuration = .6f;
|
||||
scheduleNewTask(3, delegate(){
|
||||
globalLight.GetComponent<Lichtsteuerung>().FadeToIntensity(0, .5f);
|
||||
});
|
||||
nextStep = delegate(){};
|
||||
}
|
||||
|
||||
private void scheduleNewTask(float timeFromNow, Action action){
|
||||
Task t = new(action, Time.time + timeFromNow);
|
||||
taskList.Add(t);
|
||||
}
|
||||
}
|
||||
2
Assets/AblaufKleinerStern2.cs.meta
Normal file
2
Assets/AblaufKleinerStern2.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e0d0b89432445232d940ee846097b10a
|
||||
|
|
@ -3,12 +3,13 @@ using UnityEngine;
|
|||
|
||||
public class HaseBewegung : MonoBehaviour
|
||||
{
|
||||
const float MAX_HINTERLAUF_ANGLE = 10;
|
||||
const float HINTERLAUF_TIME = 1;
|
||||
const float MAX_HINTERLAUF_ANGLE = 20;
|
||||
const float HINTERLAUF_TIME = .7f;
|
||||
public float jumpVelocityX;
|
||||
public float maxJumpVelocityY;
|
||||
public float waitingTimeBetweenJumps;
|
||||
public float earRigidity;
|
||||
public float maxEarAngularVelocity;
|
||||
public GameObject hinterlauf;
|
||||
public GameObject loeffel;
|
||||
public GameObject kopf;
|
||||
|
|
@ -18,10 +19,12 @@ public class HaseBewegung : MonoBehaviour
|
|||
private float nextJumpTime;
|
||||
private bool lookingRight;
|
||||
private float jumpStartTime;
|
||||
private float lastEarAngle;
|
||||
|
||||
private Rigidbody2D rigidBody;
|
||||
public void GoToXPosition(float x){
|
||||
xTarget = x;
|
||||
rigidBody.constraints = RigidbodyConstraints2D.FreezeRotation;
|
||||
}
|
||||
|
||||
public void Turn(){
|
||||
|
|
@ -53,6 +56,7 @@ public class HaseBewegung : MonoBehaviour
|
|||
lookingRight = true;
|
||||
nextJumpTime = 0f;
|
||||
jumpStartTime = 0;
|
||||
lastEarAngle = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
|
@ -71,8 +75,25 @@ public class HaseBewegung : MonoBehaviour
|
|||
} else {
|
||||
rigidBody.linearVelocityX = 0;
|
||||
rigidBody.linearVelocityY = math.min(rigidBody.linearVelocityY, 0f);
|
||||
rigidBody.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;
|
||||
}
|
||||
float earAngle = math.acos(earRigidity / rigidBody.linearVelocityX) / math.PIHALF * 50;
|
||||
float earAngle;
|
||||
if (rigidBody.linearVelocityX != 0){
|
||||
earAngle = math.acos(earRigidity / math.abs(rigidBody.linearVelocityX)) / math.PIHALF * 50;
|
||||
if (!lookingRight){
|
||||
earAngle *= -1;
|
||||
}
|
||||
} else {
|
||||
earAngle = 0;
|
||||
}
|
||||
if (math.abs(earAngle - lastEarAngle) / Time.deltaTime > maxEarAngularVelocity) {
|
||||
if (earAngle > lastEarAngle){
|
||||
earAngle = lastEarAngle + Time.deltaTime * maxEarAngularVelocity;
|
||||
} else {
|
||||
earAngle = lastEarAngle - Time.deltaTime * maxEarAngularVelocity;
|
||||
}
|
||||
}
|
||||
lastEarAngle = earAngle;
|
||||
loeffel.transform.localRotation = Quaternion.AngleAxis(earAngle, Vector3.forward);
|
||||
float timeFactor = (Time.time - jumpStartTime) / HINTERLAUF_TIME;
|
||||
if (timeFactor < .5f){
|
||||
|
|
@ -100,7 +121,11 @@ public class HaseBewegung : MonoBehaviour
|
|||
}
|
||||
|
||||
private void StartJump(){
|
||||
rigidBody.linearVelocityX = jumpVelocityX;
|
||||
if (lookingRight) {
|
||||
rigidBody.linearVelocityX = jumpVelocityX;
|
||||
} else {
|
||||
rigidBody.linearVelocityX = -jumpVelocityX;
|
||||
}
|
||||
rigidBody.linearVelocityY = maxJumpVelocityY;
|
||||
jumpStartTime = Time.time;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ GameObject:
|
|||
- component: {fileID: 253251732}
|
||||
- component: {fileID: 253251731}
|
||||
- component: {fileID: 253251734}
|
||||
- component: {fileID: 253251735}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
|
|
@ -256,6 +257,21 @@ MonoBehaviour:
|
|||
m_MipBias: 0
|
||||
m_VarianceClampScale: 0.9
|
||||
m_ContrastAdaptiveSharpening: 0
|
||||
--- !u!114 &253251735
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 253251730}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e0d0b89432445232d940ee846097b10a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
kleinerStern: {fileID: 786493307}
|
||||
hase: {fileID: 1354426345}
|
||||
globalLight: {fileID: 1753787405}
|
||||
--- !u!1 &786493307
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -368,7 +384,7 @@ Transform:
|
|||
m_GameObject: {fileID: 786493307}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.85, y: 6.06, z: 0}
|
||||
m_LocalPosition: {x: -2.14, y: -2.64, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
|
|
@ -436,7 +452,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 12e68d9eae98746a6b2494691fb88244, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
randomnessIntensity: 0.2
|
||||
randomnessIntensity: 0.05
|
||||
randomnessBaseAngle: 5
|
||||
randomMovementDuration: 0.7
|
||||
wobblingAngle: 8
|
||||
|
|
@ -701,7 +717,7 @@ Transform:
|
|||
m_GameObject: {fileID: 1354426345}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 3.33, y: -4.28, z: 0}
|
||||
m_LocalPosition: {x: 2.07, y: -4.25, z: 0}
|
||||
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_Children:
|
||||
|
|
@ -721,13 +737,14 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 6f767d40a49ef8ae69c8d77658c9f238, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
jumpVelocityX: 0
|
||||
maxJumpVelocityY: 0
|
||||
waitingTimeBetweenJumps: 0
|
||||
earRigidity: 0
|
||||
hinterlauf: {fileID: 0}
|
||||
loeffel: {fileID: 0}
|
||||
kopf: {fileID: 0}
|
||||
jumpVelocityX: 2
|
||||
maxJumpVelocityY: 4
|
||||
waitingTimeBetweenJumps: 0.6
|
||||
earRigidity: 0.1
|
||||
maxEarAngularVelocity: 30
|
||||
hinterlauf: {fileID: 1384506557}
|
||||
loeffel: {fileID: 1801569651}
|
||||
kopf: {fileID: 888920047}
|
||||
--- !u!70 &1354426349
|
||||
CapsuleCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -966,6 +983,103 @@ Transform:
|
|||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1753787405
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1753787408}
|
||||
- component: {fileID: 1753787407}
|
||||
- component: {fileID: 1753787406}
|
||||
m_Layer: 0
|
||||
m_Name: Global Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1753787406
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1753787405}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: bc8efbb192e1eeac280e87c344153e86, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1753787407
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1753787405}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 073797afb82c5a1438f328866b10b3f0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_ComponentVersion: 2
|
||||
m_LightType: 4
|
||||
m_BlendStyleIndex: 0
|
||||
m_FalloffIntensity: 0.5
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1
|
||||
m_LightVolumeIntensity: 1
|
||||
m_LightVolumeEnabled: 0
|
||||
m_ApplyToSortingLayers: 00000000
|
||||
m_LightCookieSprite: {fileID: 0}
|
||||
m_DeprecatedPointLightCookieSprite: {fileID: 0}
|
||||
m_LightOrder: 0
|
||||
m_AlphaBlendOnOverlap: 0
|
||||
m_OverlapOperation: 0
|
||||
m_NormalMapDistance: 3
|
||||
m_NormalMapQuality: 2
|
||||
m_UseNormalMap: 0
|
||||
m_ShadowsEnabled: 1
|
||||
m_ShadowIntensity: 0.75
|
||||
m_ShadowSoftness: 0.3
|
||||
m_ShadowSoftnessFalloffIntensity: 0.5
|
||||
m_ShadowVolumeIntensityEnabled: 0
|
||||
m_ShadowVolumeIntensity: 0.75
|
||||
m_LocalBounds:
|
||||
m_Center: {x: 0, y: -0.00000011920929, z: 0}
|
||||
m_Extent: {x: 0.9985302, y: 0.99853027, z: 0}
|
||||
m_PointLightInnerAngle: 360
|
||||
m_PointLightOuterAngle: 360
|
||||
m_PointLightInnerRadius: 0
|
||||
m_PointLightOuterRadius: 1
|
||||
m_ShapeLightParametricSides: 5
|
||||
m_ShapeLightParametricAngleOffset: 0
|
||||
m_ShapeLightParametricRadius: 1
|
||||
m_ShapeLightFalloffSize: 0.5
|
||||
m_ShapeLightFalloffOffset: {x: 0, y: 0}
|
||||
m_ShapePath:
|
||||
- {x: -0.5, y: -0.5, z: 0}
|
||||
- {x: 0.5, y: -0.5, z: 0}
|
||||
- {x: 0.5, y: 0.5, z: 0}
|
||||
- {x: -0.5, y: 0.5, z: 0}
|
||||
--- !u!4 &1753787408
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1753787405}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.111746676, y: -0.27329236, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1801569651
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1150,7 +1264,7 @@ Rigidbody2D:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1810889886}
|
||||
m_BodyType: 0
|
||||
m_BodyType: 2
|
||||
m_Simulated: 1
|
||||
m_UseFullKinematicContacts: 0
|
||||
m_UseAutoMass: 0
|
||||
|
|
@ -1313,3 +1427,4 @@ SceneRoots:
|
|||
- {fileID: 907678102}
|
||||
- {fileID: 786493310}
|
||||
- {fileID: 1354426347}
|
||||
- {fileID: 1753787408}
|
||||
|
|
|
|||
Loading…
Reference in a new issue