Does anyone know a way of adding leaning and the ability to shoot around a corner?
Clientside I can change the viewoffset to simulate leaning but the bullets still come from the original body place, and I can't modify the x and y of the viewoffset serverside.
Hm, maybe you could code a SWEP base and send your view offset vectors to server-side and manipulate the bullet trace in SWEP:ShootBullet?
Just throwing an idea out there.
Has to work on all weapons.
[QUOTE=-TB-;29348458]Has to work on all weapons.[/QUOTE]
What have you gotten so far? There is away to move the players view to an offset. As for the weapons fire pos youu might have a little difficulty as some sweps have the fire pos as the players view angles/pos.
Yeah I tried that, it works well for the Z and it shoots from the new position but it doesn't effect the X and Y. It's probably the only way to do it but it doesn't work like it should.
try making shell weapons (deriving off the one you want to change and change the small peices that arnt working).
[QUOTE=-TB-;29352117]Yeah I tried that, it works well for the Z and it shoots from the new position but it doesn't effect the X and Y. It's probably the only way to do it but it doesn't work like it should.[/QUOTE]
It should affect the x just fine. What is the cide you used?
[QUOTE=faceguydb;29400278]It should affect the x just fine. What is the cide you used?[/QUOTE]
Says X and Y aren't effected right in the notes..
[editline]e[/editline]
[b][url=http://wiki.garrysmod.com/?title=Gamemode.CalcView]Gamemode.CalcView [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b]
Try that out? Only simulated (clientside) but I don't think there's a straightforward way to do this.
[editline]e[/editline]
I was messing around and i got adjusting the roll working well enough, but it doesn't distort the player world model. If somebody made some kind of animation for this it _could_ work, i think.
[lua]local PlayerMeta = FindMetaTable("Player");
function PlayerMeta:SetLeaningRoll( r )
self.fLeaningRoll = r;
end
function PlayerMeta:IsLeaningLeft()
if( self.bIsLeaningLeft == nil ) then return false end
return self.bIsLeaningLeft;
end
function PlayerMeta:IsLeaningRight()
if( self.bIsLeaningRight == nil ) then return false end
return self.bIsLeaningRight;
end
function PlayerMeta:SetLeaningLeft(b)
self.bIsLeaningLeft = b;
end
function PlayerMeta:SetLeaningRight(b)
self.bIsLeaningRight = b;
end
function Lean_SetupMove( pl, move )
if( pl:KeyDown( IN_ATTACK2 ) ) then
pl:SetLeaningRight( !pl:IsLeaningRight() );
elseif( pl:KeyDown( IN_ATTACK ) ) then -- Just for testing, these key binds are suck lol
pl:SetLeaningLeft( !pl:IsLeaningLeft() );
end
local previousAngle = move:GetMoveAngles();
if( pl:IsLeaningRight() ) then
previousAngle.r = 20;
elseif( pl:IsLeaningLeft() ) then
previousAngle.r = -20;
else
previousAngle.r = 0;
end
move:SetMoveAngles( previousAngle );
pl:SetEyeAngles( previousAngle );
end
hook.Add( "SetupMove", "Lean_SetupMove", Lean_SetupMove );[/lua]
First Person View:
[img_thumb]http://cloud.steampowered.com/ugc/577794895743333363/D47E2DBCF41C61908E39AD4AE740C29812540973/[/img_thumb]
Third Person View:
[img_thumb]http://cloud.steampowered.com/ugc/577794895743330472/053FE6908A7CF16E4A24840343EB0FAFE1F2D034/[/img_thumb]
Notce it's just the view adjusted, meaning it'll need some kind of animation to hide the rest of his body behind the corner.
You can also adjust the origin in SetupMove, unsure of how that would work.
Yeah I was using CalcView too. That looks good. I did finally remember that there would need to be the animation for the body to be hidden and hitboxes to be effected by the lean. I was trying to make a lean with a percentage, where you could lean at 10%(some lean), 25%(more), 100%(all the way) but at any percentage. I guess that really wouldn't work out with the animations and hit boxes though.
I reported the SetViewOffsets lack of functionality to the bug tracker.
What about the [url=http://www.facepunch.com/threads/821202-Lua-Animations-API-beta] Lua Animation API[/url]? Could you use that to make them lean in third person?
[QUOTE=Fantym420;29425099]What about the [url=http://www.facepunch.com/threads/821202-Lua-Animations-API-beta] Lua Animation API[/url]? Could you use that to make them lean in third person?[/QUOTE]
Oh yeah, good idea. I'll try that. Hopefully that will move hitboxes too. Thanks.
Sorry, you need to Log In to post a reply to this thread.