Hi, i need to change the yaw of my entity. In other cases when changing the Roll i changed self.Roll to whatever i wanted. So i tried self.Yaw. This failed, i then tried self:SetAngles(self:GetAngles()+Angle(0,10,0)) this made me just move round in circles instead of moving in the right direction. What im asking is; is there another way of changing an entity's yaw?
[QUOTE=Ronon Dex;19899532]i then tried self:SetAngles(self:GetAngles()+Angle(0,10,0)) this made me just move round in circles instead of moving in the right direction.[/QUOTE]
What does that mean? Your code does change the yaw.
[QUOTE=Nevec;19899857]What does that mean? Your code does change the yaw.[/QUOTE]
It does but i need to follow the direction of my crosshair at the same time.
[lua]self:SetAngles( Angle( 0, pl:GetAimVector( ):Angle( ).y, 0 ) );[/lua]
That will make the entity follow your crosshair.
Thanks, but i also need it to spin on the yaw at the same time.
Sounds kind of weird. It most likely won't be what you're looking for.
Add CurTime to the aim yaw, or manually increase a value each frame and add it.
local ang = Entity:GetAngles()
ang:RotateAroundAxis(ang:Up(), 90)
Entity:SetAngles(ang)
Right is pitch and Forward is roll.
I'm still having the same problem. I can get it to spin but i need to go forward at the same time. Whenever i change the yaw it seems to change which way is forward in terms of the entity; thus i spin in circles and thats it.
Oh. In that case, change the yaw client side.
[QUOTE=Ronon Dex;19916049]I'm still having the same problem. I can get it to spin but i need to go forward at the same time. Whenever i change the yaw it seems to change which way is forward in terms of the entity; thus i spin in circles and thats it.[/QUOTE]
Yeah, :GetForward() is relative to the objects angles. What are you trying to do anyways? Is it supposed to go straight ahead or follow something or what?
Ok thanks now it spins but theres a slight problem. when flying it will turn 10 degrees(How much i add at a time) and then stops. It will spin properly when im not flying but not when i am flying. I'm running it in ENT:Think() clientside.
Code:
[lua]
function ENT:Think()
local p = LocalPlayer()
local moving = if self:GetVelocity()>200 then return true else return false end
if moving then
if p:KeyDown(IN_FORWARD) then
self:SetAngles(self:GetAngles()+Angle(0,10,0))
end
end
end
[/lua]
It shouldn't spin at all normally? and don't you think you should to something like this:
[lua]
local moving = self:GetVelocity()>200
[/lua]
It appears it won't spin when its moving. But when it's stationary it spins. Is this something to due with Garry's Mod or can it be fixed?
[lua]
function ENT:Think()
local p = LocalPlayer()
local moving = p:GetNWBool("FlightMode")
local tardis = p:GetNWEntity("Tardis")
local Yaw = self:GetAngles().Yaw + 10
if tardis and tardis:IsValid() then
if p:KeyDown(IN_FORWARD) then
tardis:SetAngles(Angle(0,Yaw,0))
end
end
end
[/lua]
Then do an inverse check?
[QUOTE=commander204;19918078]Then do an inverse check?[/QUOTE]
How do i do this?
I dont know you do a check somewhere to look if you are moving or not? And if instead doing if moving then etc.. do if !moving then etc...? Or did you mean it wont rotate until you move?
No it won't rotate if i'm moving
Ah well, then I can't help! Sorry I dont know then. Must be source again :downs:
Sorry, you need to Log In to post a reply to this thread.