Rotating an Entity


concommand.Add("chatclicker.start", function(ply, cmd, n)  
    if not ply:IsValid() then return end  
    if ply.chatprop != nil and ply.chatprop:IsValid() then ply.chatprop:Remove() end  
    ply.chatprop = ents.Create("prop_physics")  
    ply.chatprop:SetModel("models/extras/info_speech.mdl")  
    ply.chatprop:SetPos(ply:LocalToWorld(Vector(0, 0, 100)))  
    ply.chatprop:SetAngles(ply:GetAngles())  
    ply.chatprop:SetParent(ply)  
end)  

Trying to get this info_speech.mdl to rotate above the player

been 3 hours can’t figure it out.

Please tell me how before… :emo:

If I were you I’d make a SENT for your speech bubble so that you can define it’s think hook. In it you would set it’s angles to a different yaw each think to make it rotate. To control the speed you would delay the think.

[editline]10:45PM[/editline]

That SENT would also only need to be serverside, so stuff everything into init.lua

Ok

Did all that.

Some reason…I get no errors or anything and yet it doesn’t work. Nothing even appears.

init.lua
[lua]AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)
include(“shared.lua”)

function ENT:SpawnFunction( plr, tr )

if not tr.Hit then return end

local ent = ents.Create( self.Classname )
ent:SetPos( tr.HitPos + tr.HitNormal * 100 )
ent:Spawn()
ent:Activate()	

return ent

end

function ENT:Initialize()
self:SetModel(“models/extras/info_speech.mdl”)
self:PhysicsInit( SOLID_NONE )
self:SetMoveType( MOVETYPE_NONE )
self:SetSolid( SOLID_NONE )
self.Yaw = 0

local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end

end

function ENT:SetPlayer( pl )
self:SetPos( pl:GetPos() + pl:GetUp() * 100 )
self:SetParent( pl )

end

function ENT:Think()
self:NextThink(CurTime())
self:SetAngles( self:GetAngles() + Angle(0,1,0) )

end[/lua]

which is in lua/entities/chatbox

and

[lua]if SERVER then
AddCSLuaFile(“autorun/chatclicker.lua”)
ErrorNoHalt(“Adding Server Chatclicker Hooks…”)
concommand.Add(“chatclicker.start”, function(ply, cmd, n)
if not ValidEntity(pl) || ValidEntity(ply.chatprop) then return end
ply.chatprop = ents.Create(“chatbox”)
ply.chatprop:SetPlayer(ply)
ply.chatprop:Spawn()
ply.chatprop:Activate()
end)
concommand.Add(“chatclicker.end”, function(ply, cmd, n)
if not ValidEntity(ply) then return end
if ValidEntity(ply.chatprop) then ply.chatprop:Remove() end
ErrorNoHalt("Done!
")
end)
end

if CLIENT then
ErrorNoHalt(“Adding Client Chatclicker Hooks…”)
hook.Add(“StartChat”, “chatclicker.start”, function() RunConsoleCommand(“chatclicker.start”) end)
hook.Add(“FinishChat”, “chatclicker.end”, function() RunConsoleCommand(“chatclicker.end”) end)
ErrorNoHalt("Done!
")
end[/lua]

which is in autorun

don’t mind the ErrorNoHalts. Just for testing purposes.