This has been bothering me for a while and I haven't found a solution for it yet.
Why doesn't physics based entities emit collision sounds and effects?
I've followed several tutorials how to create lua entities, and none of them gets proper collision sounds.
Example:
shared.lua
[CODE]ENT.Type = "anim"
ENT.PrintName = "Test"
ENT.Author = "Mornedil"
ENT.Spawnable = true
ENT.AdminSpawnable = false[/CODE]
cl_init.lua
[CODE]include("shared.lua")
function ENT:Draw()
self.Entity:DrawModel()
end[/CODE]
init.lua
[CODE]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/props_vehicles/car002b.mdl")
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
end[/CODE]
It feels very weird when a huge car entity falls next to me and doesn't make a sound or shake the view.
You can take example from the sent_ball entity that's shipped with the game. [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/entities/sent_ball.lua#L98-L106[/url]
As for shaking the view, you could call this [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/ScreenShake]util.ScreenShake[/url] in the same function as above.
The source engine already has built in that different type of materials (metal, wood, etc) make different sounds upon collision, so it seems like there should be a way to tell the physics engine that "hey, this is a huge metal prop, do your thing.."
It seems pretty unnecessary to try to recreate functionality that's already there, instead of trying to access it somehow.
For example, these type of entities already emit proper physics "scrape" sounds when they drag along the ground, so there must be a way to tell it to emit physics collision sounds.
Edit:
Well, it's strange if there isn't a way to use the model's default prop data for this..
But I've tried spawning multiple downloaded entities, and they all seem to have this problem.
Biggest issue with my entity is that it can be different models, so I guess I'll have to make tables containing collision sounds for every type of material
Sorry, you need to Log In to post a reply to this thread.