[Unity] Particle system emitter look at camera

Hi!

In Unity, I want a circle shape emitter to always look at the camera.
My question is if there is a setting for this or another way to solve this in the particle system somehow or if I need to write a script, which I’d rather avoid of course.
To clarify, here’s what I have:
emitter01
And this is what I want
emitter02

Thanks for reading!

Hi !

I don’t think there is any module in Shuriken to do that. But with the right version of unity, you have ‘LookAtConstraint’ component which can help you, you will have to set your camera in ‘Source’

lookAt

Cheers

2 Likes

Thanks for your quick reply!
Didn’t know about the constraint modules, will come in handy in the future for sure.
Your solution would work with emitters that are in the same scene as the game camera.
However this won’t work when using a prefab that is to be instantiated. In that case I suppose I’d write a script that finds the camera on start and adds it as a source. It will probably work fine(except in prefab viewer?) but it’s not the sleek solution I was after, hehe :wink:

I ended up with writing a script that finds the camera and attaches it to a constraint component, as suggested by @Prot .
The script clears the constraint list and creates a brand new one with only the camera in it.
It uses the [ExecuteInEditMode] attribute, but it still works very badly when in the editor(since the editor/prefab camera isn’t Camera.main), and could be removed. In the end I didn’t care and it still works fine when in play mode.

Here’s the script for anyone interested:

FindCameraAndAddToConstraint.cs
---

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;

[ExecuteInEditMode][RequireComponent(typeof(LookAtConstraint))]
public class FindCameraAndAddToConstraint : MonoBehaviour
{
	private LookAtConstraint constraint;
	private List<ConstraintSource> clist;
	private ConstraintSource source;
	
	void Start()
	{
		Setup();
	}

	void Setup(){
		source = new ConstraintSource();
		source.sourceTransform = Camera.main.transform;
		source.weight = 1f;

		clist = new List<ConstraintSource>();
		clist.Add(source);
		
		constraint = GetComponent<LookAtConstraint>();
		constraint.SetSources(clist);
	}
}