+ Reply to Thread
Results 1 to 3 of 3

Thread: Keep upright with applyTorque() function

  1. #1
    Pizza is good... OmicroN's Avatar
    Join Date
    Apr 2008
    Location
    Frozen Hell (aka Michigan)
    Posts
    562

    Default Keep upright with applyTorque() function

    Ok i've been wondering how I should use the applyTorque() function and I took it upon myself to come up with some sorta way to do it.

    This is what I have and it even works on the prison pod that applyAngForce cannot use very well.

    Code:
    @name ApplyTorque Angkeep
    @outputs Ea:angle Save:vector M Weight
    runOnTick(1)
    E = entity():isWeldedTo()
    #Ea = angnorm(E:angles()-(owner():pos()-E:pos()):toAngle())
    Ea = angnorm(E:angles())
    if(E:boxSize():length()/2 > 10){
        M = E:boxSize():length()/3
    }else{ M = M = E:boxSize():length()/4 }
    if(first()){
        Save = E:pos():setZ(owner():shootPos():z())
        Weight = E:mass()
    }
    if(!E:isPlayerHolding()){
        E:applyTorque( shiftR( vec( angnorm(-Ea-E:angVel()) ) ) * (M^1.4) )
        E:applyForce((Save-E:pos())*(E:mass()^1.4)-E:vel()*(E:mass()/2))
        if(Weight <= 200){
            E:setMass(200)
        }        
    }else{E:setMass(Weight)}
    This is just a base for you to learn from, since I figure it's for advanced users i'll just let you sort it out and remake it any way you feel the need.

  2. #2
    No u Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    4,582

    Default Re: Keep upright with applyTorque() function

    A new function! Could you explain a bit more how it works? :S
    SVN Tutorial
    My SVN:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    Get dropbox and get 250 MB extra space: Dropbox

  3. #3
    Developer Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    3,109

    Default Re: Keep upright with applyTorque() function

    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr

+ Reply to Thread

Similar Threads

  1. applyTorque Tutorial
    By Fizyk in forum Expression 2 Discussion & Help
    Replies: 75
    Last Post: 2 Weeks Ago, 03:12 PM
  2. Help with applyTorque
    By AndyDLP in forum Installation and Malfunctions Support
    Replies: 13
    Last Post: 11-16-2009, 12:55 AM
  3. Keep Upright
    By Archil in forum Expression 2 Discussion & Help
    Replies: 11
    Last Post: 05-13-2009, 08:59 AM
  4. E2 - Look At Function
    By Jeremydeath in forum Wiremod Addons & Coding
    Replies: 14
    Last Post: 04-25-2009, 03:41 AM
  5. New E2 Function
    By Officer Tibbles in forum Ideas & Suggestions
    Replies: 1
    Last Post: 02-24-2009, 11:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots