- Home /
Is there a way to rotate Shuriken particles and have working normal maps?
Hi there, I've just been testing out Shuriken using a particle material that has a tangent-space normal map.
The billboard particles look ok if they aren't rotated, but if I change their Start Rotation to 180 degrees, it now looks as if the light source has been has been rotated by 180 degrees. If you let the start rotation be random, then each particle appears to be bit by a different light source.
It is my understanding that the apparent light direction shouldn't change on the particles - is there a way to stop this happening, or is it just that you can't rotate normal-mapped particles?
I can't really give you a clear answer >.< But I can provide a solution! If you spawn them as actual objects, then they will for sure update the light on their textures. Now, I'm not exactly sure what you need... so I'm gonna provide an example where you hit a "trap" and then it spawns a bunch at an area and they start to travel before dying after a set time.
Here's the code for how to do it. (You'll have to apply this on an empty GameObject or somn with the "Is Trigger" set to True, in a Collider Component.
using UnityEngine;
using System.Collections;
public class Trap : $$anonymous$$onoBehaviour
{
public GameObject ShurikenPrefab; //Fill this in with the shuriken prefab
public GameObject ShurikenSpawnPoint; //Fill this in with the object you want these to spawn at from the Scene
public float RandomSpawnRange = 5; //This is subject to change (for tweaking in editor)
public int NumberOfShurikens = 50; //You can change this in the Inspector tab while in the Editor for tweaking
public float Lifetime = 5;
void OnTriggerEnter(Collider other)
{
//spawns a ton of shurikens (shuriken movement is handled within it's own "Controller" script)
for(int i = 0; i < NumberOfShurikens; i++)
{
GameObject go = GameObject.Instantiate(ShurikenPrefab, new Vector3(
(ShurikenSpawnPoint.transform.position.x + Random.Range(0f, RandomSpawnRange)),
(ShurikenSpawnPoint.transform.position.y + Random.Range(0f, RandomSpawnRange)),
(ShurikenSpawnPoint.transform.position.z + Random.Range(0f, RandomSpawnRange))),
Quaternion.identity);
Destroy(go, Lifetime);
}
}
}
You'll have to make a Shuriken prefab to plugin to the script. Quad's are better than planes, cuz they are only 2 tris, ins$$anonymous$$d like 50 or wutever the planes are.
Here's the script for the shuriken prefab. If this isn't plugged in there, the thing won't fly :/ or spin...
using UnityEngine;
using System.Collections;
public class ShurikenController : $$anonymous$$onoBehaviour
{
public Vector3 ShurikenTranslateVector;
public Vector3 ShurikenRotateVector;
void Update()
{
//applies the Translate Vector to the shuriken every frame
transform.position += ShurikenTranslateVector;
//applies the Rotate Vector to the shuriken every frame
transform.localRotation += ShurikenRotateVector;
}
}
Hi Acr1m, Your solution doesn't really apply in my case, as I'm trying to specifically get the lighting to work on billboard particles that have been spawned from Unity3D's Shuriken particle system.
These particles are much more light-weight than having to spawn multiple game objects, and much more render-efficient too!
moved this over to a comment ins$$anonymous$$d, in order to clear out the answer section so somebody with a "real" answer can help you out :P
Your answer
Follow this Question
Related Questions
Converting vortex effect from legacy to Shuriken 1 Answer
Shuriken values in shader code? 0 Answers
Normal maps problem 1 Answer
Vanish the Shuriken particle system clone 1 Answer
Particle system does not re-emit until Start Lifetime elapsed 4 Answers