Just as the title says I’m trying to make some dust trail or landing effects based on animation events and for some reason the prefab is working fine, no errors what so ever the thing is the prefab is spawning with 0,1 scale which means is visibly not showing up (This is 2D game) but the object does spawn I can even see it on the hierarchy and when I select the boject when I manually change the Scale to 1,1 you can see the animation prefab as it should. English not the best sorry for typos I’ll attach images and code I’m using
So this is what should Spawn:
This is what is spawning:
As you can see the prefab is indeed spawning which means the code is working I’m also running a Debug.Log to see what is coming out and it seems to be the correct information:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimations : MonoBehaviour
{
[Header("Effects")]
[SerializeField] GameObject runStopDust;
[SerializeField] GameObject jumpDust;
[SerializeField] GameObject landingDust;
private AudioManager m_audioManager;
// Animation Events
// These functions are called inside the animation files
public void Start()
{
m_audioManager = AudioManager.instance;
}
void SpawnDustEffect(GameObject dust, float dustXOffset = 0)
{
if (dust != null)
{
// Set dust spawn position
Vector3 dustSpawnPosition = transform.position + new Vector3(0, 0.0f, 0.0f);
GameObject newDust = Instantiate(dust, dustSpawnPosition, Quaternion.identity) as GameObject;
// Turn dust in correct X direction
newDust.transform.localScale = newDust.transform.localScale.x * new Vector3(0, 1, 1);
}
}
void AE_runStop()
{
m_audioManager.PlaySound("RunStop");
// Spawn Dust
float dustXOffset = 0.6f;
SpawnDustEffect(runStopDust, dustXOffset);
}
void AE_footstep()
{
m_audioManager.PlaySound("Footstep");
}
void AE_Jump()
{
m_audioManager.PlaySound("Jump");
// Spawn Dust
SpawnDustEffect(jumpDust);
}
void AE_Landing()
{
m_audioManager.PlaySound("Landing");
// Spawn Dust
SpawnDustEffect(landingDust);
}
}
That’s the whole code of Player animations where sounds and animations prefabs effects are being controlled, theres an audio manager that all it does is to configure the sound lvs and names of the sounds effects
Now coming to the issue this is the animations and the prefabs:
So the animation landing does have an event that is suppose to call AE_Landing where you already saw a code run and should make a noise and instantiate a prefab (with it does BOTH) however the prefab comes with scale 0,1 instead of 1,1.
They do have a reference in the player.
How I fix this bug because it seems to be a weird error or something cause no error is being displayed and for some reason it keeps coming out as 0,1 thanks.




