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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

AddForce physic Problem

Discussion in 'Scripting' started by Cabecca, Nov 4, 2015.

  1. Cabecca

    Cabecca

    Joined:
    Nov 4, 2015
    Posts:
    2
    Hey Guys, I need a little help

    i am using Addforce to move the forks of the Forklift.
    the problem that i cant resolved is how to stop the forks.
    i cant use in the rigibody <Is Kinematic> because i need to drive the forklift.
    <constraints> this also ruled out.

    when i press the up button. i apply addforce to the florks. but when i release the button with the weight of the load the forks decended.
    I need to stay in position when release the button.



    Code (JavaScript):
    1. function Start() {
    2.     rb = GetComponent.<Rigidbody>();
    3.     }
    4.  
    5. function SubirBrazo (){
    6.    
    7.     while(botonUpOn){
    8.            
    9.             rb.AddForce(Vector3.up * thrust);
    10.            
    11.             }
    12.  
    13.  
    I appreciate any help
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Do you need a rigidbody for that part? You can just move the collider (if it's a child of the forklift). Alternatively look into ForceMode (the missing parameter in AddForce).
     
    Cabecca likes this.
  3. Wowo51

    Wowo51

    Joined:
    Oct 12, 2015
    Posts:
    25
    Have you looked at 'Fixed Joint'? It seems to be just what you are looking for.
     
  4. Cabecca

    Cabecca

    Joined:
    Nov 4, 2015
    Posts:
    2
    i cant use "fixed Joint" because i cant move the florks up and down.
     
  5. Wowo51

    Wowo51

    Joined:
    Oct 12, 2015
    Posts:
    25
    You would have to turn on the fixed joint when the button is released.
     
    Cabecca likes this.