Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Collider and Movement Problem

Discussion in 'Scripting' started by mbahadirb, Aug 6, 2010.

  1. mbahadirb

    mbahadirb

    Joined:
    Jul 8, 2010
    Posts:
    21
    Hi

    This code works when I dont add collider but if I add collider to the same mesh or to its child, Turning() function doesnt work but AddForce works. Looking forward to hear what I am doing wrong:D

    Have Fun
    Bahadır Boge

    Code (csharp):
    1.  
    2.  
    3. function FixedUpdate () {
    4.     //Apply forward force
    5.     rigidbody.AddForce ( transform.forward * throttle );
    6.     Turning();
    7. }  
    8.  
    9. function Turning () {
    10.     rigidbody.AddTorque( Input.GetAxis ( "Horizontal" ) * transform.up * rotationSpeed );
    11.     rigidbody.AddTorque( Input.GetAxis ( "Vertical" ) * transform.right * rotationSpeed / 5 );
    12. }
    13.  
     
  2. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    282
    Test if this work:

    Code (csharp):
    1.  
    2. function FixedUpdate () {
    3.    //Apply forward force
    4.    rigidbody.AddForce ( transform.forward * throttle );
    5.  
    6.    rigidbody.AddTorque( Input.GetAxis ( "Horizontal" ) * transform.up * rotationSpeed );
    7.    rigidbody.AddTorque( Input.GetAxis ( "Vertical" ) * transform.right * rotationSpeed / 5 );
    8. }
    9.