代码拉取完成,页面将自动刷新
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SController : MonoBehaviour
{
public ParticleSystem ps;
public ParticleSystem.Particle[] particles;
public int speed=5;
public float k=0.05f;
public float b=1;
public Transform tr;
void Start()
{
ps=gameObject.GetComponent<ParticleSystem>();
particles=new ParticleSystem.Particle[ps.maxParticles];
tr.position=new Vector3(0,0,0);
}
// Update is called once per frame
void FixedUpdate()
{
int num=ps.GetParticles(particles);
float x,y,z;
float r,nowr,rate;
for (int i=0;i<num;++i){
Vector3 v=particles[i].position;
x=v.x;
y=v.y;
z=v.z;
nowr=(new Vector3(0,y,0)-particles[i].position).magnitude;
r=y*y*k+b;
if (nowr<=0.5){
x=1;
z=0;
}else{
rate=r/nowr;
x=x*rate;
z=z*rate;
}
tr.position=new Vector3(x,y,z);
tr.RotateAround(new Vector3(0,y,0),Vector3.up,speed);
particles[i].position=tr.position;
}
ps.SetParticles(particles,num);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。