|
Post by Korv on May 21, 2015 14:29:39 GMT
How to reset transform of game object in "OnDespawned" event ?
Thanks in advance.
|
|
|
Post by DarkTonic Dev on May 21, 2015 15:13:10 GMT
Sorry I don't understand the question. Please ask another way and tell me what the problem is you're trying to solve.
|
|
|
Post by Korv on May 21, 2015 15:25:00 GMT
Sorry, problem was resolved.
Short description if someone will have the same problem. I'm using pool system with Simple Way Point (SWP). When object spawned it started move by path using SWP. I had problem that during respawning object appear at "old" position (where it was killed). So fixed this by this simple script:
using UnityEngine; using System.Collections; using SWS;
public class KillableCleanDespawn : MonoBehaviour {
splineMove move;
void OnDespawned () { move = GetComponent("splineMove") as splineMove; move.Stop(); move.ResetToStart ();
GetComponent<Transform> ().localPosition = new Vector3(0, 0, 0); }
void OnSpawned () { move = GetComponent("splineMove") as splineMove; move.StartMove(); } }
|
|
|
Post by DarkTonic Dev on May 21, 2015 16:36:51 GMT
Yes this is normal. As mentioned in the readme OnSpawned method should be used instead of Awake and Start for most initialization code. Glad you got it working 
|
|