您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
31 行
784 B
31 行
784 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class BoatFoamGenerator : MonoBehaviour
|
|
{
|
|
public Transform boatTransform;
|
|
private ParticleSystem.MainModule module;
|
|
public ParticleSystem ps;
|
|
public float waterLevel = 0;
|
|
private Vector3 offset;
|
|
|
|
private void Start()
|
|
{
|
|
module = ps.main;
|
|
offset = transform.localPosition;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
var pos = boatTransform.TransformPoint(offset);
|
|
pos.y = waterLevel;
|
|
transform.position = pos;
|
|
|
|
var fwd = boatTransform.forward;
|
|
fwd.y = 0;
|
|
var angle = Vector3.Angle(fwd.normalized, Vector3.forward);
|
|
module.startRotation = angle * Mathf.Deg2Rad;
|
|
}
|
|
}
|