+ Reply to Thread
Results 1 to 8 of 8

Thread: Making something just stay where it is

  1. #1
    Wirererer bobthe2lol is on a distinguished road bobthe2lol's Avatar
    Join Date
    Aug 2007
    Location
    US,NY
    Posts
    309

    Default Making something just stay where it is

    It wont work. I tryed applyforce to the entity's pos, but it jsut goes flying off to the left, so i dont know how i would get a variable of the entities pos when spawned that wont ever change, and make the entity stay there. How can i do this?

  2. #2
    Drone Madman
    Lyinginbedmon has a spectacular aura about Lyinginbedmon has a spectacular aura about Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,652

    Default Re: Making something just stay where it is

    Well you'd need to persist it on spawning, using if(first()){Pos = entity():pos()}

    Then, you'd need to subtract Pos from the entity's current position, Vec = Pos - entity():pos()

    Then, applyForce(Vec + $Vec*5), to stabilise so you'd need to persist Vec as well.

    If that fails, you'd need to multiply Vec by a number that varies on the entity's weight, but with chips I don't think that's needed.

    Resulting in:
    @persist Pos:vector Vec:vector

    if(first()){Pos = entity():pos()}

    interval(10)
    Vec = Pos - entity():pos()

    applyForce(Vec + $Vec*5)

    Which should do fine, except bear in mind that chips generally spawn welded to a surface until you hit them with the physgun (Assuming they spawn on the world). In which case, the expression wouldn't move period from where it was spawned.

  3. #3
    Wirererer bobthe2lol is on a distinguished road bobthe2lol's Avatar
    Join Date
    Aug 2007
    Location
    US,NY
    Posts
    309

    Default Re: Making something just stay where it is

    Thank you. I have the chips model set to a phx plate so ill have to use the multiplier, also whats with the if first() part?

  4. #4
    Drone Madman
    Lyinginbedmon has a spectacular aura about Lyinginbedmon has a spectacular aura about Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,652

    Default Re: Making something just stay where it is

    first() triggers the if function when the chip is first spawned, so it sets Pos, which is then where the chip stays.
    The Olympus Technologies drones, totally not SkyNet in Gmod form.
    Cronus: The Ultimate Drone, definitely SkyNet in Gmod form.
    The gBrain Project, the drone controls system that thinks it's better than you

    Need to learn how to make your own drones? Check out Drones with a Mad Scientist for my tutorials on how to do it.

  5. #5
    Wirererer bobthe2lol is on a distinguished road bobthe2lol's Avatar
    Join Date
    Aug 2007
    Location
    US,NY
    Posts
    309

    Default Re: Making something just stay where it is

    Sorry -snip-
    Last edited by bobthe2lol; 07-08-2009 at 07:53 AM.

  6. #6
    Inactive UselessFodder is on a distinguished road UselessFodder's Avatar
    Join Date
    Jun 2009
    Location
    Shittown, GA
    Posts
    22

    Default Re: Making something just stay where it is

    Quote Originally Posted by bobthe2lol View Post
    I see. Ok, well i cant get it to work, i want it to fly around with key commands.

    So what i want it to do is:

    Hover
    point at my mouse
    Fly at my mouse, like using forward()
    fly at variable speeds, but all it does is flys slowly in a line back and forth... can you help me? I know im sorta asking for code, but i dont know what to do.
    Give us the code you have so far.
    ...

  7. #7
    Wirererer bobthe2lol is on a distinguished road bobthe2lol's Avatar
    Join Date
    Aug 2007
    Location
    US,NY
    Posts
    309

    Default Re: Making something just stay where it is

    I am now working on a project, where i want it to hover +50 in the z axis, but to be able to move around on the X and Y axis. I have this, but it just spazes when i use it.
    E2 Code:
    1. @persist Pos:vector PPos:vector Vec:vector Ang:angle
    2. @trigger all
    3. if(first()){
    4. Pos = entity():isWeldedTo():pos()
    5. }
    6. X = entity():isWeldedTo():pos():x()
    7. Y = entity():isWeldedTo():pos():y()
    8. entity():setMass(0)
    9. interval(10)
    10. PPos = ((Pos - entity():isWeldedTo():pos())*500)+vec(-X,-Y,50)
    11. entity():isWeldedTo():applyForce(PPos + $PPos*5)
    OOOps wrong section sorrryyyy!!!!
    Last edited by bobthe2lol; 07-08-2009 at 08:06 AM.

  8. #8
    Wirererer DarkMonkey is on a distinguished road DarkMonkey's Avatar
    Join Date
    Jun 2008
    Posts
    201

    Default Re: Making something just stay where it is

    It might be because you're setting the mass to 0, pretty sure that's inadvisable

+ Reply to Thread

Similar Threads

  1. help with making a HUD
    By eduardo in forum Technical Support
    Replies: 15
    Last Post: 06-13-2009, 05:57 PM
  2. Making props' stay in your head's position with E2.
    By Quantum in forum Technical Support
    Replies: 5
    Last Post: 04-11-2009, 11:22 AM
  3. I need help with making my car.
    By Vintage in forum Technical Support
    Replies: 9
    Last Post: 12-11-2008, 08:39 AM
  4. I need help with making my car.
    By Vintage in forum Wiremod General Chat
    Replies: 5
    Last Post: 11-29-2008, 05:55 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