Search Unity

script for collide

Discussion in 'Scripting' started by josemauriciob, Jun 3, 2011.

  1. josemauriciob

    josemauriciob

    Joined:
    Mar 5, 2009
    Posts:
    662
    hi.
    i have a cube box 3D with collide .... no motion
    and the character can not pass through it

    but, if i apply some rotation, .... now the character, can go through the 3D cube,
    like when a ghost through walls, identical.

    how can i fix this, or some idea please
    thanks
     
  2. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    How are you applying rotation? If you are doing it using the Transform.Rotation, then the physics engine will not see it. But, if you change it over to setting the rotation in phyisics every frame. (i.e. rigidbody.angularRotation=Vector3(0,10,0); ) You will see that it does collide. However.... No phyisics movement can affect a Character collider. So, the best answer is to then swap to a non Character collider object.

    You can adjust movement by setting the velocity of the object directly. (i.e. rigidbody.velocity=Vector3(x,rigidbody.velocity.y, z); ) View attachment $WebPlayer.rar
     
    Last edited: Jun 9, 2011