I am currently working on a entity, but the prop's dimensions that are used aren't to my satisfaction. I've done like half an hour of 'research' on the idea of using the Enable Matrix to change the size based on an axis. I haven't got a clue on what to do, the examples provided didn't really help me understand on the wiki either. The only thing I know fully about it is how it is supposed to be ran clientside. I don't think pasting any of my code will help, It's just a standard physics entity that has a material set; but I could be wrong about pasting code.
Best regards, me.
Entity/EnableMatrix only changes the visual appearance, not the physics scale, but if that is what you want, the example on the wiki is all you need. If you want to also scale the physics of the prop, for that you will need Entity/SetModelScale, however that can only scale the same in all directions, if you only want to scale it on a single direction (axis), you will most likely need to use the Entity/PhysicsInitConvex and make a custom physics object.
Yea, I'm looking for EnableMatrix. I'm newer to lua so I'm most likely doing something wrong. I tried the example in cl_init.lua but It returns with the "attempt to call method 'EnableMatrix' (a nil value)"
error in console. My code for that specific line that gives the error is:
ENT:EnableMatrix( "RenderMultiply", mat )
That is not how you use it, you tried to call the function on the ENT table (which is not the entity itself, but rather it's data). Can you post the whole files of the entity?
Also, I am not good at explaining this kind of stuff, you will be better off watching some tutorials rather than trying to understand me explaining shit, Code Blue has some nice tutorials
https://www.youtube.com/channel/UCFpuE-Qjn4EWqX-VJ_l7pbw/playlists
I have watched a few of his tutorials a bit ago but I don't think he has anything for my specific situations.
My files are as follows:
cl_init.lua:
include( "shared.lua" )
resource.AddFile("Renegadesboard/materials/rboard1/Fennekin.vtf")
resource.AddFile("Renegadesboard/materials/rboard1/Fennekin.vmt")
//just pasted the example to test it
local scale = Vector( 1, 1, 4 )
local mat = Matrix()
mat:Scale( scale )
ENT:EnableMatrix( "RenderMultiply", mat )
Init.lua
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/hunter/plates/plate1x1.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
//self:SetModelScale(8,0) Not using this right now since it does every axis.
self:SetMaterial("rboard1/Fennekin")
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
end
shared.lua
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/hunter/plates/plate1x1.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
//self:SetModelScale(8,0) Not using this right now since it does every axis.
self:SetMaterial("rboard1/Fennekin")
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
end
Alright, you need to put the code inside a function, and since it should be clientside only, put this in cl_init:
function ENT:Initialize()
local scale = Vector( 1, 1, 4 )
local mat = Matrix()
mat:Scale( scale )
self:EnableMatrix( "RenderMultiply", mat ) // self refers to the entity itself, ENT is only a table of data for the entity
end
Screw the broken code tags :P
Ah, I had a feeling it needed a function but I didn't know you could call Initialize in a clientside. Other than that, it works just fine, so thank you very much for the help!
Sorry, you need to Log In to post a reply to this thread.