Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Disabling / re-Enabling wagon makes character slide off

Discussion in 'Physics' started by protopop, Nov 17, 2016.

  1. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,544
    I have a character that jumps on and off a moving wagon. I change the parent when he jumps on it from the terrain ti the wagon, and reverse than when he jumps off.

    Works great.

    Except, if i disable and then re-enable the wagon gameobject at anytime, he no longer moves with the object when he is riding it, instead he just kind of starts sliding off until he falls off the back.

    this only hapens when i disable and then re enable the wagon, so i leave it on all the time and just hide its mesh renders so its invisible, and turn them on when it needs to be seen.

    Any ideas why? even wild ones?
     
  2. JamhammerRob

    JamhammerRob

    Joined:
    Jan 15, 2016
    Posts:
    13
    I'm not sure about any back end changes that unity does in this regard, but it sounds like you need to find a new reference to the wagon after it's been disabled. Check for null references when you try jumping on the object again, or adjust your methods to check for the wagon's transform as being null before attaching the character.
     
    protopop likes this.
  3. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,544
    Thanks JamhammerRob:) Ill look into this. Yeah, its the bizarest thing. Its literally the only item in BrightRidge that i havent been able to figure out for a couple of years. I feel like you might be on the right track with the transform being null at some point.