Hello, ive been currently working on something, a grenade launcher to be exact. the launcher spawns these grenades, but they seem to be invisible. the particles work, but the model itself is invisible.
here is my shared.lua
[code]
ENT.Type = "anim"
ENT.PrintName = "Grenade"
ENT.Author = "buu342"
ENT.Contact = ""
ENT.Purpose = ""
ENT.Instructions = ""
/*---------------------------------------------------------
OnRemove
---------------------------------------------------------*/
function ENT:OnRemove()
end
/*---------------------------------------------------------
PhysicsUpdate
---------------------------------------------------------*/
function ENT:PhysicsUpdate()
end
/*---------------------------------------------------------
PhysicsCollide
---------------------------------------------------------*/
function ENT:PhysicsCollide(data,phys)
if data.Speed > 80 then
self.Entity:EmitSound("Grenade.ImpactHard",100,math.random(95,105))
end
local impulse = -data.Speed * data.HitNormal * .4 + (data.OurOldVelocity * -.6)
phys:ApplyForceCenter(impulse)
end
[/code]
int.lua
[code]
AddCSLuaFile('init.lua')
AddCSLuaFile('shared.lua')
include("shared.lua")
/*---------------------------------------------------------
Initialize
---------------------------------------------------------*/
function ENT:Initialize()
local Trail = ents.Create("info_particle_system")
Trail:SetPos(self:GetPos())
Trail:SetKeyValue( "effect_name", "pipebombtrail_red" )
Trail:SetParent( self )
Trail:SetKeyValue( "start_active", "1" )
Trail:Spawn()
Trail:Activate()
self:SetModel("models/weapons/w_models/w_grenade_grenadelauncher.mdl")
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:DrawShadow( false )
self.StopExp = false
-- Don't collide with the player
self:SetCollisionGroup( COLLISION_GROUP_INTERACTIVE )
self:SetNetworkedString("Owner", "World")
local phys = self:GetPhysicsObject()
self.Explode = CurTime() + 2.2
if (phys:IsValid()) then
phys:Wake()
end
end
local exp
/*---------------------------------------------------------
Think
---------------------------------------------------------*/
function ENT:Think()
if self.Explode and CurTime()>=self.Explode then
self.StopExp = true
self.Explode = nil
self:EmitSound("BaseExplosionEffect.Sound")
local ExplodeEffect = ents.Create("info_particle_system")
ExplodeEffect:SetPos(self:GetPos())
ExplodeEffect:SetKeyValue( "effect_name", "Explosion" )
ExplodeEffect:SetKeyValue( "start_active", "1" )
ExplodeEffect:Spawn()
ExplodeEffect:Activate()
util.BlastDamage(self, self.Owner, self:GetPos(), 170,45)
self:Remove()
end
end
function ENT:Touch(ent)
self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
if (ent:IsNPC() or ent:IsPlayer()) and ent:IsValid() and self.StopExp == false then
if self:GetVelocity():Length() >= 100 then
self.Explode = CurTime()
end
end
end
[/code]
cl_int.lua
[code]
include('shared.lua')
/*---------------------------------------------------------
Draw
---------------------------------------------------------*/
function ENT:Draw()
self.Entity:DrawModel()
end
[/code]
Thanks!
You forgot to add AddCSLuaFile("cl_init.lua") in init.lua.
did, still not working :/
i am making a wild gues with this,
did you make the grenade the way that the inside is see trough and the outside is textured,
if so it might've happened that the textures are inverted
[QUOTE=buu342;39669334]
[code]
/*---------------------------------------------------------
Draw
---------------------------------------------------------*/
function ENT:Draw()
self.Entity:DrawModel()
end
[/code]
[/QUOTE]
Why self.Entity:DrawModel()?
Try use: self:DrawModel()
Sorry, you need to Log In to post a reply to this thread.