+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 15

Thread: Letting a plate(E2) hover at it's current position.

  1. #1
    Inactive vortexnl is on a distinguished road vortexnl's Avatar
    Join Date
    Sep 2007
    Posts
    102

    Default Letting a plate(E2) hover at it's current position.

    I want to let my E2 chip hover at its own altitude, although I want to grab it and reposition his position without him flying back to his old location.

    It's for a E2 camera im working on, it's controlled by mouse. and I want to put a thruster on it so I can fly around freely.
    [IMG]http://img39.imageshack.us/img39/5140/imtehpro.jpg[/IMG][URL="http://img291.imageshack.us/img291/3626/p10102811fc5.gif"]
    [/URL]

  2. #2
    Drone Madman
    Lyinginbedmon will become famous soon enough Lyinginbedmon will become famous soon enough Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,023

    Default Re: Letting a plate(E2) hover at it's current position.

    Best way to do that would be an upward applyForce to negate the chip's gravity. With gravity negated by the force, the chip would hover in place, not unlike in a vacuum.

  3. #3
    Inactive motorbikeking1 is on a distinguished road motorbikeking1's Avatar
    Join Date
    Feb 2009
    Posts
    31

    Default Re: Letting a plate(E2) hover at it's current position.

    gravity works through vacuums :P

    if your not sure on the code, you would need to do something along the lines of

    Code:
    applyforce(Prop:up() * Prop:mass() * gravity())
    

  4. #4
    Banned Nicolai1 will become famous soon enough Nicolai1's Avatar
    Join Date
    Nov 2008
    Location
    Denmark.
    Posts
    1,002

    Default Re: Letting a plate(E2) hover at it's current position.

    No, if the plate was upside down it would just apply downward force, this is the code (Working as I've made it before):

    Code:
    @inputs Ent:entity
    runOnTick(1)
    Ent:applyForce(vec(0, 0, 9.8)*Ent:mass())
    

  5. #5
    Wire Sofaking Echo51 will become famous soon enough Echo51's Avatar
    Join Date
    Feb 2009
    Location
    Denmark
    Posts
    1,108

    Default Re: Letting a plate(E2) hover at it's current position.

    look up gravity on wikipedia.org if the 9.8 isent perfect, it might drop a slighty bit..
    Proud of my non-existant life...
    In russia, Expression 2 codes you!
    Quote Originally Posted by Snowden42 View Post
    Nooblishious? That's a signature keeper.

  6. #6
    Lurker pl0x is an unknown quantity at this point pl0x's Avatar
    Join Date
    Aug 2008
    Posts
    222

    Default Re: Letting a plate(E2) hover at it's current position.

    9.81 is gravity. on earth. at sea level. in this universe.

  7. #7
    Spucatum Tauri
    Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    3,441

    Default Re: Letting a plate(E2) hover at it's current position.

    Gmod gravity is not 9.81
    Gmod gravity is whatever sv_gravity is.. Which is 600 normally.

    There should be an automatic kick in the butt when someone uses "9.8" in a post, when "gravity" is mentioned in the thread on wiremod.com.

    edit: *Kick*
    Last edited by Bull; 05-07-2009 at 01:01 PM. Reason: Automatic butt kick system
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That
    The Great Report Button Quiz.

  8. #8
    Wire Sofaking mjmr89 is on a distinguished road mjmr89's Avatar
    Join Date
    Mar 2008
    Posts
    501

    Default Re: Letting a plate(E2) hover at it's current position.

    Unfortunately gravity, acceleration, force, etc does *NOT* work how it should in gmod. Even if you use a figure like 600 somewhere in your calculations, it won't work... I've tried MANY times. There is, however, an upward force needed to counteract gravity for a given mass. I tried to get a formula for this, but it jumps around and is pretty damn erratic. If you have, like you say a camera, you only have to calculate this force once. Something like this:

    e2 Code:
    1. @inputs Ent:entity
    2. @persist Calibration
    3. runOnTick(1)
    4.  
    5. Calibration += entity():vel():z()
    6.  
    7. EE:applyForce(Calibration*vec(0,0,1))

    It will struggle a bit but it will eventually get there. You might want to mess with a multiplier or something on Calibration. Obviously, do this with gravity on. Once it settles and stops moving up and down, save the number using a debugger or something.

    You could probably just make one E2 that does this and change the E2 to the weight of the prop you'll end up using + 1 for the weight of the expression that I assume you'll be attaching to said prop.

    But when I came into this topic I was thinking about another way to do it.

    e2 Code:
    1. @inputs ENT
    2.  
    3. runOnTick(1)
    4.  
    5. Held = entity():owner:isBeingHeld() #I'm not really sure of the function, whatever tells you if its being frozen or not
    6. Pos = ENT:pos()
    7. SomeMultiplier = ???
    8.  
    9. if((~Held & !Held) | first()) #if someone just stopped holding it
    10. {HoldPos = Pos} #make that position it stopped being held at the position to stick to
    11.  
    12. ENT:applyForce(SomeMultiplier*(HoldPos - Pos - ENT:vel())

    Hope this helps.

    EDIT: Forgot about adding in the air friction part of it.
    Last edited by mjmr89; 05-07-2009 at 04:47 PM.

  9. #9
    Inactive motorbikeking1 is on a distinguished road motorbikeking1's Avatar
    Join Date
    Feb 2009
    Posts
    31

    Default Re: Letting a plate(E2) hover at it's current position.

    Some code im using atm is

    Code:
    Force = (TargetPos - Prop:pos()) * 5 - Prop:vel()
    Force *= Prop:mass()
    Prop:applyForce(Force)
    
    works like a charm, all you need to do is find the correct multiplyer and your there, dunno where i got 5 from lol thats just from code i took from Paper Clip to fiddle around with some stuff.

  10. #10
    Wirererer Aura is on a distinguished road Aura's Avatar
    Join Date
    Sep 2008
    Posts
    159

    Default Re: Letting a plate(E2) hover at it's current position.

    Just do something like

    applyForce(-entity():vel()*entity():mass())

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Similar Threads

  1. Wiremod not letting any other SVN be added
    By Rensai in forum Help & Support
    Replies: 6
    Last Post: 03-01-2009, 06:00 PM
  2. Adv Dupe Save: Hover Tower Plate
    By Grocel in forum Advanced Gates
    Replies: 2
    Last Post: 02-26-2009, 08:47 AM
  3. Current Big Project?
    By Eagleguy125 in forum Wiremod General Chat
    Replies: 55
    Last Post: 01-06-2008, 02:29 AM
  4. How to get the current Z position of a player?
    By Beer in forum Help & Support
    Replies: 4
    Last Post: 07-25-2007, 01:04 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