- Home /
How can I make particles respect the rotation of objects, and fix error "!IsFinite(outDistanceForSort)"
I'm making a game that looks like a football game. In my game is a special combo that you're kicking the ball very fast and I created an effect for that. It looks like an explosion in forward direction. The problem is that when I am spinning my character to the right or the left and do the combo - the effect is "exploding" toward the same direction always. Just like it keeps exploding on the z axis even if my character is turned to another way. How I make it "explode" to the direction my character face?
Another question: I want to use the particles on one part of my character and the enemy to show on which team he belongs to. When I put the particles on one of the meshes, the particles doesn't show up and I get that error !IsFinite(outDistanceForSort). It is a character I created in blender. How can I make the particles show?
Answer by Statement · Mar 16, 2011 at 01:50 PM
Hi Michael. It seems you have either of two cases as to why your particles travel into world-z.
The first case is if you have animated your particles in world coordinates, then they will not respect the orientation of your object. You should animate your particles in local coordinates.
The second case is if you have animated your particles in local coordinates, you may be placing your object without any rotation. This can happen by mistake if you are creating the particle as a prefab, and position it somewhere and forget to set its rotation. However if you have it parented to some object (as your character), then it is much more likely that you would be in the first case - where you animate the particles for world coordinates rather than local.
The particles are animating in local coordinates and I created it as 2 diffrent prefabs, one for charging the energy and the other for the explotion, The prefabs shows up one after the other only when I click a button. Both prefabs have the problem.
How can i set the rotation?
You can set the prefabs forward vector the same as your targets forward vector. For instance, if you are creating a prefab and you have a direction the ball is going to be shot in, you can set your clones rotation like so: effect.transform.forward = motion.normalized; Or if you want to parent something to a node you could have the node point in the proper direction and parent it such as effect.transform.parent = thatNode; effect.transform.position = Vector3.zero; effect.transform.rotation = Quaternion.identity; Or if you are doing this through the editor, just rotate it properly.
If you use local coordinates in editor and have it parented to some object, then you can think of the blue axis being forward. (r/g/b color = x/y/z axis)
You can also create a rotation from any directional vector using Quaternion.LookRotation http://unity3d.com/support/documentation/ScriptReference/Quaternion.LookRotation.html
I can you explane more please? It's hard to me to understand what you said...
Answer by efge · Mar 16, 2011 at 01:49 PM
Answer to your 1st question: Disable Simulate In World Space for the Ellipsoid Particle Emitter.