Closed Thread
Results 1 to 8 of 8

Thread: e2 ApplyForce Stabilization Help

  1. #1
    Wire Noob Dr. Breen's Avatar
    Join Date
    Feb 2010
    Posts
    11

    Default e2 ApplyForce Stabilization Help

    Im not sure if this is the right section to post help for e2 problems, so if not, then move this if you want.

    Ok, so heres the e2...


    Code:
    @name fighter test
    @inputs 
    @outputs 
    @persist 
    @trigger 
    
    runOnTick(1)
    Temp=entity(),Entity=(Temp:getConstraints():count( ) >0 ? Temp:isWeldedTo() : Temp)
    
    Angle=-Entity:angles()*15-Entity:angVel()*2
    Center=Entity:massCenter(),Right=Entity:right(),Fo rward=Entity:forward(),Up=Entity:up()
    Entity:applyForce((vec(0,0,18)-Entity:vel())*Entity:mass())
    Leverage=Entity:inertia():length()
    
    Entity:applyOffsetForce( Up *Angle:pitch(),Center-Forward*Leverage)
    Entity:applyOffsetForce(-Up *Angle:pitch(),Center+Forward*Leverage)
    Entity:applyOffsetForce( Up *Angle:roll() ,Center-Right *Leverage)
    Entity:applyOffsetForce(-Up *Angle:roll() ,Center+Right *Leverage)
    #Entity:applyAngForce(Angle*Leverage) #This can replace the above 6 lines
    The problem is: the sentence (Entity=(Temp:getConstraints():count() >0 ? Temp:isWeldedTo() : Temp) I dont need this part of the code because it causes the game to lag when I spawn the e2 on tremendously welded/parented contraptions. Is there anyway to get rid of that one code but still allow the e2 to work? Thanks.

    P.S I did not make this code, as some of you may find out. I, assuming this was on the Gmod Wiki for all to find, downloaded it assuming that anyone was allowed to download the code if credit was given to the original creator (chinoto)
    Last edited by Bull; 08-03-2010 at 10:19 PM.

  2. #2
    Spucatum Tauri Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    6,010

    Default Re: e2 ApplyForce Stabilization Help

    Code:
    Entity = entity():isWeldedTo()
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

    Quote Originally Posted by Anticept View Post
    By the way, Bull is in charge.

  3. #3
    Wire Noob Dr. Breen's Avatar
    Join Date
    Feb 2010
    Posts
    11

    Default Re: e2 ApplyForce Stabilization Help

    omg thank you so much. ill be sure to give u a little credit if i ever decide to release my contraption to public

  4. #4
    Wire Noob maku220's Avatar
    Join Date
    Jun 2011
    Posts
    9

    Default Re: e2 ApplyForce Stabilization Help

    But what's the difference between "isWeldedTo()" and "isConstrainedTo()"

  5. #5
    Wirererer gen-3's Avatar
    Join Date
    Mar 2011
    Location
    CERN
    Posts
    335

    Default Re: e2 ApplyForce Stabilization Help

    Where it says replace the previous six lines, do that. You're using a lot more ops than you need to calling applyOffsetForce four times. You can also increase the runOnTick to 10 or even 100, it doesn't make much of a difference but will decrease lag as well.
    isWeldedTo simply looks for welds and ignores other constraints, while isConstrainedTo would give you something that it's no-collided to, for example.
    My brain's last firmware update got corrupted. Now I can only see in base 7.

    Add me on Steam. and get new friends for a change

    And keep track of my somewhat relevant screenshots for fun things mostly but not entirely in gmod!

    The square root of 763,932,023 is 27639.32023

  6. #6
    Wirererer Yevano's Avatar
    Join Date
    May 2010
    Location
    US
    Posts
    221

    Default Re: e2 ApplyForce Stabilization Help

    Quote Originally Posted by gen-3 View Post
    You can also increase the runOnTick to 10 or even 100, it doesn't make much of a difference but will decrease lag as well.
    It won't decrease lag, there's no difference with runOnTick(). runOnTick(1) is the same as runOnTick(1337).

  7. #7
    ส็็็็็็็็็็็็็็็็ส็็ ็็็็็ Dav1d's Avatar
    Join Date
    May 2009
    Posts
    1,118

    Default Re: e2 ApplyForce Stabilization Help

    Quote Originally Posted by gen-3 View Post
    You can also increase the runOnTick to 10 or even 100, it doesn't make much of a difference but will decrease lag as well.
    runOnTick(n) just looks for a true or false value, it doesn't matter what the heck it is - as long as it isn't false/invalid/zero/null, the E2 will be triggered every tick.

  8. #8
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: e2 ApplyForce Stabilization Help

    Quote Originally Posted by maku220 View Post
    But what's the difference between "isWeldedTo()" and "isConstrainedTo()"
    Not all constraints are welds. If the only constraint on an entity is an axis constraint, isWeldedTo() will return noentity.
    Also, please do not bump threads. Closed.

Closed Thread

Tags for this Thread

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