1. Post #1
    Gold Member
    Hypershadsy's Avatar
    February 2008
    2,420 Posts
    It's supposed to jump around after I +use it. Instead, it does nothing. It does have physics, however.

    cl_init.lua
    function ENT:Draw ()
    	self.Entity:DrawModel();
    end
    include("shared.lua");

    shared.lua
    ENT.Type = "anim"
    ENT.Base = "base_gmodentity"
    ENT.PrintName = "Jumpy"
    ENT.Author = "Hypershadsy"
    ENT.Information = "Info"
    ENT.Category = "Fun + Games"
    
    ENT.Spawnable = true
    ENT.AdminSpawnable = true

    init.lua
    include("shared.lua")
    AddCSLuaFile("cl_init.lua")
    AddCSLuaFile("shared.lua")
    
    function ENT:SpawnFunction( ply, tr )
    	if ( !tr.Hit ) then return end
    	local SpawnPos = tr.HitPos + tr.HitNormal * 16
    	local ent = ents.Create( "sent_test" )
    		ent:SetPos( SpawnPos )
    	ent:Spawn()
    	ent:Activate()
    	return ent
    end
    function ENT:Initialize()
    	self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
    	self.Entity:PhysicsInit( SOLID_VPHYSICS )
    	local phys = self.Entity:GetPhysicsObject()
    	if (phys:IsValid()) then
    		phys:Wake()
    	end
    	self.Entity:SetCollisionBounds( Vector( -16, -16, -16 ), Vector( 16, 16, 16 ) )
    end
    function ENT:Use()
    	timer.Create("node",1,0,function()
    		local DirX = math.Rand(-100,100)
    		local DirY = math.Rand(-100,100)
    		local DirZ = math.Rand(-100,100)
    		self.Entity:GetPhysicsObject():ApplyForceCenter( Vector( DirX, DirY, DirZ ) )
    	end )
    end

  2. Post #2
    Gold Member
    Morcam's Avatar
    September 2008
    1,537 Posts
    A force of 100 probably just can't move it. Add a couple more zeros.

  3. Post #3
    Gold Member
    Hypershadsy's Avatar
    February 2008
    2,420 Posts
    Worked. Thread over

  4. Post #4
    Gold Member
    Morcam's Avatar
    September 2008
    1,537 Posts
    Worked. Thread over
    For reference, gravity applies a force of 600 units * mass * deltatime. Assuming deltatime is 0.015, that's 315 units of force. Thus it doesn't move. You could disable gravity, though. Then it would fly around, rather than jump.