- Home /
Making a particle effect parallel to the slope of a terrain
I want to instantiate a particle effect and make it parallel to a slope, but I do not know how to do it.
Answer by Harry_Drew · Jun 05, 2021 at 11:33 AM
I don't get quite what you mean by the question please can you be a bit more specific. If your meaning that you have a constant gradient slope and you want particles to follow the slope as shown below.
First you need to find the incline of the slope. do Mathf.Atan(heightChange / widthChange) * Mathf.RadToDeg.
Then take that angle and instantiate the particle system at that angle. Quaternion InstantiateAngle = Quaternion.Euler(new Vector3(0f,0f, angle)); Instantiate(particleSystemPrefab, transform.position, InstanceAngle);
Btw the code has not been tested so there may be a few mistakes but the principle should work. Thanks
Your answer
Follow this Question
Related Questions
Make an instantiated object match the slope of the terrain 1 Answer
Instantiate not shooting in right direction 1 Answer
rotating gameobject according to terrain before instantiate 1 Answer
Unity Invisible Collision With Slope [Rotation Issue] 0 Answers
transform position and rotation of instantiated object 1 Answer