Tp3 + start TP4
This commit is contained in:
parent
57a40d426b
commit
3a7ce962e7
112 changed files with 63386 additions and 45 deletions
34
TP3/Assets/Scripts/PlatformMove.cs
Normal file
34
TP3/Assets/Scripts/PlatformMove.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class PlatformMove : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Transform start;
|
||||
[SerializeField] Transform end;
|
||||
[SerializeField]
|
||||
[Range(0.5f, 10f)]
|
||||
float loop_time;
|
||||
|
||||
float t;
|
||||
float direction = 1.0f;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
t += Time.fixedDeltaTime * direction;
|
||||
transform.position = Vector3.Lerp(start.position, end.position, t / loop_time);
|
||||
if (t > loop_time)
|
||||
{
|
||||
direction *= -1;
|
||||
}
|
||||
if (t < 0)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue