Bringe dem Esel mit Maria das Laufen bei
This commit is contained in:
parent
8f71e675c6
commit
f610b443e2
12 changed files with 1327 additions and 24 deletions
40
Assets/AblaufKleinerStern3.cs
Normal file
40
Assets/AblaufKleinerStern3.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class AblaufKleinerStern3 : MonoBehaviour
|
||||
{
|
||||
public GameObject mariaAufEsel;
|
||||
|
||||
private Action nextStep;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
nextStep = AuftrittMariaUndJoseph;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space)){
|
||||
nextStep();
|
||||
}
|
||||
}
|
||||
|
||||
private void AuftrittMariaUndJoseph(){
|
||||
mariaAufEsel.GetComponent<FigurMitBeinenBewegung>().GoToXPosition(1);
|
||||
nextStep = AuftrittKleinerStern;
|
||||
}
|
||||
|
||||
private void AuftrittKleinerStern(){
|
||||
nextStep = EinStueckWeiter;
|
||||
}
|
||||
|
||||
private void EinStueckWeiter(){
|
||||
nextStep = Abgang;
|
||||
}
|
||||
|
||||
private void Abgang(){
|
||||
nextStep = delegate(){};
|
||||
}
|
||||
}
|
||||
2
Assets/AblaufKleinerStern3.cs.meta
Normal file
2
Assets/AblaufKleinerStern3.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be39dfb47ed7a3c0b89e66f9a0dbdf23
|
||||
72
Assets/FigurMitBeinenBewegung.cs
Normal file
72
Assets/FigurMitBeinenBewegung.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
public class FigurMitBeinenBewegung : MonoBehaviour
|
||||
{
|
||||
public GameObject[] wobblingParts;
|
||||
public float[] wobblingMaxAngles;
|
||||
public bool[] wobblingInversed;
|
||||
public float wobblingPeriod;
|
||||
public float movementVelocity;
|
||||
|
||||
private float movementStartTime;
|
||||
private float targetPositionX;
|
||||
private bool moving;
|
||||
private bool wobbling;
|
||||
private float lastPhase;
|
||||
|
||||
public void GoToXPosition(float x) {
|
||||
targetPositionX = x;
|
||||
movementStartTime = Time.time;
|
||||
moving = true;
|
||||
wobbling = true;
|
||||
if (x > transform.position.x) {
|
||||
transform.rotation = Quaternion.identity;
|
||||
} else if (x < transform.position.x) {
|
||||
transform.rotation = Quaternion.AngleAxis(180, Vector3.up);
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
targetPositionX = transform.position.x;
|
||||
moving = false;
|
||||
wobbling = false;
|
||||
lastPhase = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (moving){
|
||||
float deltaX = Time.deltaTime * movementVelocity;
|
||||
if (targetPositionX - transform.position.x < 0){
|
||||
deltaX *= -1;
|
||||
}
|
||||
if ((transform.position.x - targetPositionX) * (transform.position.x + deltaX - targetPositionX) <= 0){
|
||||
transform.position = new Vector2(targetPositionX, transform.position.y);
|
||||
moving = false;
|
||||
} else {
|
||||
transform.position += Vector3.right * deltaX;
|
||||
}
|
||||
}
|
||||
if (wobbling){
|
||||
float phase = math.sin((Time.time - movementStartTime) * math.PI2 / wobblingPeriod);
|
||||
if (!moving && phase * lastPhase <= 0){
|
||||
wobbling = false;
|
||||
phase = 0;
|
||||
}
|
||||
lastPhase = phase;
|
||||
for (int i = 0; i < wobblingParts.Length; i++){
|
||||
float angle = phase * wobblingMaxAngles[i];
|
||||
if (wobblingInversed[i]){
|
||||
angle *= -1;
|
||||
}
|
||||
wobblingParts[i].transform.localRotation = Quaternion.AngleAxis(angle, Vector3.forward);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/FigurMitBeinenBewegung.cs.meta
Normal file
2
Assets/FigurMitBeinenBewegung.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8b2b3cf9e9fd7e2078e1e71f1cb3938a
|
||||
1174
Assets/Scenes/kleiner_Stern_3.unity
Normal file
1174
Assets/Scenes/kleiner_Stern_3.unity
Normal file
File diff suppressed because it is too large
Load diff
7
Assets/Scenes/kleiner_Stern_3.unity.meta
Normal file
7
Assets/Scenes/kleiner_Stern_3.unity.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e8b8435ddd7638d5a96da213464e814f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 0
|
||||
width: 132
|
||||
height: 666
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: 0.40496087, y: 0.89557004}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: ee993b28a6a422463a15d88a2e57a5d4
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Maria auf Esel - Eselbein1_0: -2314117792804241221
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 0
|
||||
width: 131
|
||||
height: 643
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: 0.69153017, y: 1.0462925}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: c33502a410fe423538737deeb445325a
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Maria auf Esel - Eselbein2_0: -6640877963095185480
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 0
|
||||
width: 243
|
||||
height: 680
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: 0.5258131, y: 0.94277257}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: 87be1ac543cacb5d8bfd16021a4003b5
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Maria auf Esel - Eselbein3_0: -4514926496411855965
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 0
|
||||
width: 214
|
||||
height: 657
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: 0.79311264, y: 1.015557}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: 33b614e7f023635b39d50ba10fe0fd46
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Maria auf Esel - Eselbein4_0: 2075278806595872617
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 643
|
||||
width: 798
|
||||
height: 1088
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: 0.24846677, y: 0.51729584}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: 38df9f30a8a6cb2b780fde372695ff18
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Maria auf Esel - Eselkopf_0: 2698551319815246180
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 379
|
||||
width: 282
|
||||
height: 750
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: 0.7446762, y: 0.90981036}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: d52d92352666e59cea3e14ed23318bfa
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Maria auf Esel - Schwanz_0: 2774470072328476467
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
Loading…
Reference in a new issue