You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

53 lines
1.4 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Networking.Client;
public class FloatingOnWater : MonoBehaviour
{
bool characterInWater = false;
public ConnectedClients clientData;
private List<string> Names;
public GameObject lilypad;
private void Start()
{
for(int i = 0; i < clientData.AllClients.Count; i++)
{
Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
}
}
void OnTriggerEnter(Collider other)
{
for(int i = 0; i < Names.Count; i++)
{
if (other.gameObject.name == Names[i])
{
characterInWater = true;
}
}
}
IEnumerator FloatSinkCoroutine(Vector3 endPosition)
{
float elapsedTime = 0;
Vector3 startPosition = lilypad.transform.position;
float time = 0.8f;
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
lilypad.transform.position = endPosition;
}
public void Animate()
{
StartCoroutine(FloatSinkCoroutine(new Vector3(0, 1, 0)));
}
public void returnToPosition()
{
StartCoroutine(FloatSinkCoroutine(new Vector3(0, 0, 0)));
}
}