- Home /
Particle system not to follow the GameObject?
Hello Devs,
GOAL :
I am trying to re-create a wind effect for my game. The wind should resemble more or less a swirl wind or a mini tornado. To give a picture representation, I would like the particle effect to follow the circular arrows like in the picture below.
They should start at the bottom & reach the top.
METHOD I USED :
I thought that if I have particles moving up on the Y axis and If I happen to rotate the GObject, I could get a similar effect. But I ended up have my particles following me rather than moving in circles.
HYPOTHESIS:
But I think that I need add any code to the GObject and such an effect is possible through shuriken particle system. I am just stuck right and I do not know, what kind of an approach I should use.
What would be the best way to do it using a particle system?
Thank you,
Karsnen.
Answer by KingKongFu · Dec 20, 2012 at 03:46 PM
Just a though if you are just rotating the particle on the Y axis then it may be doing what "you want it to do" but not how you want it to do it. You may have to send the particle out a bit on the up vector to make it spin not just rotate. Im just think out loud here. Hope that helps
camera code
var target : Transform;
var distance = 10.0;
var xSpeed = 250.0;
var ySpeed = 120.0;
var yMinLimit = -20;
var yMaxLimit = 80;
private var x = 0.0;
private var y = 0.0;
var smoothTime = 0.3;
private var xSmooth = 0.0;
private var ySmooth = 0.0;
private var xVelocity = 0.0;
private var yVelocity = 0.0;
private var posSmooth = Vector3.zero;
private var posVelocity = Vector3.zero;
@script AddComponentMenu("Camera-Control/Mouse Orbit smoothed")
function Start () {
var angles = transform.eulerAngles;
x = angles.y;
y = angles.x;
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
function LateUpdate () {
if (target) {
x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
xSmooth = Mathf.SmoothDamp(xSmooth, x, xVelocity, smoothTime);
ySmooth = Mathf.SmoothDamp(ySmooth, y, yVelocity, smoothTime);
ySmooth = ClampAngle(ySmooth, yMinLimit, yMaxLimit);
var rotation = Quaternion.Euler(ySmooth, xSmooth, 0);
// posSmooth = Vector3.SmoothDamp(posSmooth,target.position,posVelocity,smoothTime);
posSmooth = target.position; // no follow smoothing
transform.rotation = rotation;
transform.position = rotation * Vector3(0.0, 0.0, -distance) + posSmooth;
}
}
static function ClampAngle (angle : float, min : float, max : float) {
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp (angle, min, max);
}
How do you make it spin? I am trying to rotate the particle effects using Rotation by Speed. i.e. I am trying to add some angular velocity. It does not make any difference.
There are two things here that I can see.
1: $$anonymous$$ove the object upwards
2: $$anonymous$$ake it spin around a local axis
So what I would do is to take the orbital camera like this one I put above. Just mod that a bit and ins$$anonymous$$d of a camera you can put the particle effect you want on it and then have that move around the position.
$$anonymous$$ing$$anonymous$$ongFu -> why do need to use Camera in the first place? I am missing you here.
No, dont use the camera thats just the idea. What I was thinking is use the camera code to help you figure out how to get the particle effect to move around in a cylinder rater than spin/ rotate in a single Y value.
A arc ball cam does just that. I revolves around a center point but does not touch that point.
If you think about it a particle effect is 2d so it will look the same way in any direction you look at it. So to get your spin I think that you will have to move it around not just rotate it in one position. I may be wrong with my assumptions here seeing I just started to learn unity. But its kinda the same as a billboard from other game engines so I would assume that its the same for unity
Here we go I found a general purpose scripts that can help you out http://wiki.unity3d.com/index.php?title=ArcBall∾tion=edit
This way the effect will circle around the target just make the center of the tornado spiral thingy the target and all should be good I think