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?
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?
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.
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?
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.
Sorry -snip-
Last edited by bobthe2lol; 07-08-2009 at 07:53 AM.
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.
OOOps wrong section sorrryyyy!!!!E2 Code:
@persist Pos:vector PPos:vector Vec:vector Ang:angle @trigger all if(first()){ Pos = entity():isWeldedTo():pos() } X = entity():isWeldedTo():pos():x() Y = entity():isWeldedTo():pos():y() entity():setMass(0) interval(10) PPos = ((Pos - entity():isWeldedTo():pos())*500)+vec(-X,-Y,50) entity():isWeldedTo():applyForce(PPos + $PPos*5)
Last edited by bobthe2lol; 07-08-2009 at 08:06 AM.
It might be because you're setting the mass to 0, pretty sure that's inadvisable
Bookmarks