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

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

  1. #1
    Wirererer vortexnl's Avatar
    Join Date
    Sep 2007
    Posts
    114

    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.

  2. #2
    Wiremod Helper Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,659

    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
    Wire Amateur motorbikeking1's Avatar
    Join Date
    Feb 2009
    Posts
    32

    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's Avatar
    Join Date
    Nov 2008
    Location
    Denmark.
    Posts
    1,251

    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's Avatar
    Join Date
    Feb 2009
    Location
    Denmark
    Posts
    1,489

    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
    Wirererer pl0x's Avatar
    Join Date
    Aug 2008
    Posts
    238

    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's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    6,005

    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

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

  8. #8
    Wire Sofaking mjmr89's Avatar
    Join Date
    Mar 2008
    Posts
    555

    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:

    [highlight=e2]
    @inputs Ent:entity
    @persist Calibration
    runOnTick(1)

    Calibration += entity():vel():z()

    EE:applyForce(Calibration*vec(0,0,1))

    [/highlight]

    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.

    [highlight=e2]
    @inputs ENT

    runOnTick(1)

    Held = entity()wner:isBeingHeld() #I'm not really sure of the function, whatever tells you if its being frozen or not
    Pos = ENTos()
    SomeMultiplier = ???

    if((~Held & !Held) | first()) #if someone just stopped holding it
    {HoldPos = Pos} #make that position it stopped being held at the position to stick to

    ENT:applyForce(SomeMultiplier*(HoldPos - Pos - ENT:vel())
    [/highlight]

    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
    Wire Amateur motorbikeking1's Avatar
    Join Date
    Feb 2009
    Posts
    32

    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's Avatar
    Join Date
    Sep 2008
    Posts
    165

    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 12 LastLast

Similar Threads

  1. Wiremod not letting any other SVN be added
    By Rensai in forum Installation and Malfunctions Support
    Replies: 6
    Last Post: 03-01-2009, 06:00 PM
  2. Current Big Project?
    By Eagleguy125 in forum Wiremod General Chat
    Replies: 55
    Last Post: 01-06-2008, 02:29 AM
  3. How to get the current Z position of a player?
    By Beer in forum Installation and Malfunctions 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
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots