• How to make something constantly happen.
    11 replies, posted
Hi, I am making a SENT that lets you fly around the map. I was wondering how I would constantly keep applyforcecenter updating, I tried ENT:Think but only does it about every second. This probably sounds like a dumb question but I am an idiot. Also I was wondering if there was a way to use applyforceoffset to reach a desired angle. Thanks.
ENT:Think runs multiple times a second (About 60 AFAIK), post the code so we can help you.
Here is what I have on this computer, I have heavily modified what is here now but here is basically it: [Code] function ENT:Think() if(driver:IsValid()) then if (driver:KeyDown(IN_ATTACK2)) then local clk = not clk end if (clk == true) then veh:SetAngle(Angle(0,yaw,0)) veh:SetPos(p) local driver = veh.GetDriver()) if (driver:KeyDown(IN_FORWARD)) then p = p+veh:GetForward() end if (driver:KeyDown(IN_RUN)) then local p = p+veh:GetForward()*10 end if (driver:KeyDown(IN_BACK)) then local p = p-veh:GetForward() end if (driver:KeyDown(IN_MOVELEFT)) then local yaw = yaw+1 end if (driver:KeyDown(IN_MOVERIGHT)) then local yaw = yaw-1 end if (driver:KeyDown(IN_JUMP)) then local p = p+Vector(0,0,1) end if (driver:KeyDown(IN_ALT1)) then local p = p-Vector(0,0,1) end else local p = veh:GetPos()+Vector(0,0,30) local yaw = veh:GetAngles():y end end end [/Code]
[QUOTE=Iskuri;19100325]Here is what I have on this computer, I have heavily modified what is here now but here is basically it: [Code] code [/Code][/QUOTE] If you're using ENT:Think() correctly then it should run every frame or something. We would probably need to see the context in which you are using it.
OK, I will upload the entire code when I get home. Could I please have some help with the getting the entity to the right angle as well?
It should be commonly known by now that a Think hook and ENT:Think() run at different speeds.
Shut up CptFuzzies. Stop abusing the fact that you know marginally more than a person completely new to Lua. Iskuri, what you want to use in this case is a physics think hook. [url]http://wiki.garrysmod.com/?title=ENT.PhysicsUpdate[/url]
Thank you very much, Rambo. I am indeed a complete noob, so thanks for helping me know slightly more. :D
This is an earlier version, iRzilla, but thanks for taking an interest. I have got everything working now so thank you all.
[QUOTE=andrewmcwatters;19102459]It should be commonly known by now that a Think hook and ENT:Think() run at different speeds.[/QUOTE] I know you hate boxes but now you're just asking for them.
Sorry, you need to Log In to post a reply to this thread.