Start Size and Rotation
- Game Development course
- Intermediate
- Lesson 40/83
- 4 min
Learn particle start with Start Size and Start Rotation.
Start Size (Initial Size)
The initial size of particles when spawned is defined by the startSize property in the main module. You can assign either a fixed value (such as 1.0f) or a random size between two constants. Randomizing sizes gives particles a significantly more natural and organic look.
var main = ps.main;
main.startSize = 0.5f;Start Rotation (Initial Rotation)
The initial angle at which particles launch is determined by startRotation. To prevent all particles from facing the exact same direction, a random initial angle between 0 and 360 degrees is often assigned. This makes leaves, dust, or smoke scatter much more realistically.
var main = ps.main;
main.startRotation = 45f;Practice Assign Size and Rotation Values
Assign 2.0f to main.startSize and 90f to main.startRotation. Print results with Debug.Log("Boyut: " + main.startSize); and Debug.Log("Donus: " + main.startRotation); respectively.
Starter code
using System;
public class MainModule
{
public float startSize = 1.0f;
public float startRotation = 0f;
}
public static class Debug
{
public static void Log(object message) => Console.WriteLine(message);
}
public class Program
{
public static void Main()
{
MainModule main = new MainModule();
// Boyut ve donus degerlerini guncelleyip konsola yazdir
}
}Sample solution
using System;
public class MainModule
{
public float startSize = 1.0f;
public float startRotation = 0f;
}
public static class Debug
{
public static void Log(object message) => Console.WriteLine(message);
}
public class Program
{
public static void Main()
{
MainModule main = new MainModule();
main.startSize = 2.0f;
main.startRotation = 90f;
Debug.Log("Boyut: " + main.startSize);
Debug.Log("Donus: " + main.startRotation);
}
}Expected output
Boyut: 2 Donus: 90
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which main module property defines the initial size of particles when they first appear in the scene?
- startSpeed
- startLifetime
- startColor
- startSize Correct answer
Explanation: startSize specifies the initial scale of particles at the time they spawn.
2 Define Start Size
main.____ = 2.5f;
main.startSize = 2.5f;
Explanation: startSize is used to define the particle size at the moment of spawning.
3 Initial Values
| Term | Meaning |
|---|---|
startSize |
Particle's initial size at birth |
startRotation |
Particle's initial rotation angle |
Random Between Two Constants |
Random values between two boundaries |
startSpeed |
Initial launch speed of the particle |