Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unexpected behaviour when positioning Rigidbody 2D object

Discussion in '2D' started by Uncleared, Jan 13, 2018.

  1. Uncleared

    Uncleared

    Joined:
    Jan 23, 2016
    Posts:
    5
    So I'm using the Unity 5.6.1 2D Robot Boy Controller from the Standard Assets. Essentially what I'm trying to do is spawn it at certain positions. I am working on a multiplayer game so I cannot simply have the controllers already inside the scene. Every time a player joins, a new one is spawned.

    Whenever I try to position the controller in the scene, the controller goes there for a split second, then suddenly flies off in another direction, or glitches through the floor.

    Things I have already tried:
    -Setting the transform position
    -Setting the Rigidbody2D position
    -Setting both Rigidbody2D and transform position
    -Disabling the Controller script and Rigidbody2D until I have positioned the controller, in case that when its spawned, it does some weird physics thing

    None of them work, and this is very strange. Any help would be very appreciated. Thanks in advance!
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    5,397
    It's difficult to know what's wrong based on what you said. If it's flying to another location, that sounds like something else is setting its position.
    If it glitches through the floor, that could be the same, but sounds like the possibility that it could be a collider issue?
    Does the controller always fly off to the same spot? (not including glitching through the floor lol)
    Or is it random?
     
  3. ryandotdee

    ryandotdee

    Joined:
    Feb 6, 2015
    Posts:
    15
    It sounds like it is clipping something, have you tried setting the rigidbody to kinematic? That should help rule physics in or out, you could also put some debug on the controllers colliders to see if it is colliding with anything.
     
  4. Uncleared

    Uncleared

    Joined:
    Jan 23, 2016
    Posts:
    5
    I managed to fix it just by moving the game to a another scene that was empty. If there was a collider that made everything go wrong, I couldn't find it. But thanks for the suggestions everybody!
     
  5. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    5,397
    Glad you solved it. :)