]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Level_Elements/PlatformBird.cs
Neues Level
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Level_Elements / PlatformBird.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class PlatformBird : MonoBehaviour
6 {
7     public float speed;
8
9     public Transform rightTurningPoint;
10     public Transform leftTurningPoint;
11
12     bool movingRight;
13
14     // Update is called once per frame
15     void Update()
16     {
17         if (transform.position.x > leftTurningPoint.position.x)
18         {
19             movingRight = false;
20
21         }
22         else if (transform.position.x < rightTurningPoint.position.x)
23         {
24             movingRight = true;
25         }
26
27         if (movingRight)
28         {
29             transform.position += transform.right * (Time.deltaTime * speed);
30         }
31         else
32         {
33             transform.position -= transform.right * (Time.deltaTime * speed);
34         }
35     }
36 }