Moving Paltform added und placed in Prefab Folder
This commit is contained in:
30
Assets/AssetsFORELLE/Script/MovingPlatform.cs
Normal file
30
Assets/AssetsFORELLE/Script/MovingPlatform.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MovingPlatform : MonoBehaviour
|
||||
{
|
||||
public float speed;
|
||||
public int startingPoint;
|
||||
public Transform[] points;
|
||||
private int i;
|
||||
|
||||
void Start()
|
||||
{
|
||||
transform.position = points[startingPoint].position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Vector2.Distance(transform.position, points[i].position)<0.02f)
|
||||
{
|
||||
i++;
|
||||
if(i==points.Length)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
transform.position = Vector2.MoveTowards(transform.position, points[i].position, speed * Time.deltaTime);
|
||||
}
|
||||
}
|
11
Assets/AssetsFORELLE/Script/MovingPlatform.cs.meta
generated
Normal file
11
Assets/AssetsFORELLE/Script/MovingPlatform.cs.meta
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 625cd88d174208441afb47c124a0f800
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user