I've made a basic crate entity by following [URL="http://steamcommunity.com/groups/Slt-St/discussions/4/558749824835027686/"]this example[/URL].
But the entity doesn't get any physics impact sounds (when it collides with something).
How can I make the entity act and sound like a spawned prop_physics?
Is there a way to base my entity off prop_physics?
The model of the entity determines the sound it makes on collision; I believe that functionality resides in base entity, not prop_physics. What model are you setting your entity to, and does it emit sounds when spawned as a prop_physics?
[QUOTE=zerf;49362818]The model of the entity determines the sound it makes on collision; I believe that functionality resides in base entity, not prop_physics. What model are you setting your entity to, and does it emit sounds when spawned as a prop_physics?[/QUOTE]
That's what I thought too, but I am using a regular crate model (and have tried the bathtub model too). The props with the same models do emit sounds upon collision, but the entity only emits damage sounds (when you hit it), and scrape sounds (when it's dragging along the ground).
Another thing I noticed is that the entity doesn't create the player view shake effect that prop_physics do when they impact the ground nearby with enough mass and force.
In the clientside Initialize function for your custom entity, are you doing
[code]
function ENT:Initialize()
self:SetSolid(SOLID_VPHYSICS)
end
[/code]
That was the problem for me when I encountered this issue.
[QUOTE=Z0mb1n3;49363472]In the clientside Initialize function for your custom entity, are you doing
[code]
function ENT:Initialize()
self:SetSolid(SOLID_VPHYSICS)
end
[/code]
That was the problem for me when I encountered this issue.[/QUOTE]
It didn't work, there's still no sound.
init.lua
[CODE]AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
function ENT:Initialize()
self:SetModel( "models/items/item_item_crate.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
function ENT:Use( activator, caller )
return
end
function ENT:Think()
end[/CODE]
cl_init.lua
[CODE]include('shared.lua')
function ENT:Initialize()
self:SetSolid(SOLID_VPHYSICS)
end
function ENT:Draw()
self.BaseClass.Draw(self) -- Overrides Draw
--self:DrawEntityOutline( 1.0 ) -- Draw an outline of 1 world unit.
self:DrawModel() -- Draws Model Client Side
end[/CODE]
shared.lua
[CODE]ENT.Name = "Supply Crate"
ENT.Base = "base_gmodentity"
ENT.Type = "anim"
ENT.PrintName= "Supply Crate"
ENT.Author= "Mornedil"
ENT.Contact= "N/A"
ENT.Purpose= "Contains rewards"
ENT.Instructions= "Break the crate open for rewards"
ENT.Spawnable = true
ENT.AdminSpawnable = false[/CODE]
Try deleting ENT.Base and ENT.Type, and instead doing
[code]DEFINE_BASECLASS("base_entity")[/code]
Might work, might not.
[QUOTE=Z0mb1n3;49364197]Try deleting ENT.Base and ENT.Type, and instead doing
[code]DEFINE_BASECLASS("base_entity")[/code]
Might work, might not.[/QUOTE]
Gave me error spam in the console, but I appreciate the suggestion
Edit: Isn't there a way to just base the entity off prop_physics?
Seems like there are a lot more differences than just sound (like not getting the model's QC variables), and it seems like a waste to try to re-code the behavior of a prop_physics when it already exists.
I mean, prop_physics does all this automatically:
[CODE]function ENT:OnTakeDamage( damage )
self:SetHealth(self:Health()-damage:GetDamage())
end
function ENT:Think()
if self:Health() <= 0 then
self:Remove()
end
end[/CODE]
And the above doesn't even include creating the crate gibs.
Sorry, you need to Log In to post a reply to this thread.