Quantcast
Viewing all articles
Browse latest Browse all 42

moving gameobject from state machine behaviour/different code result from inside OnStateExit()

Hello! I'm having trouble with a state machine behaviour, so far I have the following function: override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Instantiate(parSys, new Vector3(-0.038f, 0.05f, 0.694f), Quaternion.identity); newPos = new Vector3(Random.Range(-2f, 2f), 0.05f, Random.Range(-2f, 2f)); objectParent.transform.position = newPos; objectModel.transform.position = newPos; } My objective is to instantiate a particle system at the position of a game object , then teleport that gameobject to a random position, both when an animation clip has run through. The function does instantiate the particle system, it doesn't teleport the GameObject though. Strange thing is: when I put the same code into a function in a monobehaviour, it does wat I want it to. I also tried calling that function from the OnStateExit(), doesn't move the object either. Is there something I'm missing about state machine behaviours? Help would be much appreciated!

Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>