• Follow an entity.
    11 replies, posted
Hi everyone. I'm trying to follow an entity, like a RPG misile, so when I shoot it, I do: [lua]function PlayerMT:Spec( ent ) self:Spectate( OBS_MODE_CHASE ) self:SpectateEntity( ent ) end function PlayerMT:UnSpec() self:Spectate( OBS_MODE_NONE ) self:UnSpectate() end[/lua] But I have some problems: First one, when I UnSpectate, player makes a minijump :P. Nothing important but it makes me angry haha. Another one: when I finish spectating, NPCs leave me, without attacking me... The last one: I don't see hud after finish spectating. Any Idea?
Not sure that it's the best solution, but calling Player:Spawn() and then setting their position & angles back restores the HUD without losing weapons or ammo or anything like that - it might fix the NPC problem too. Not sure if you need to set the health back too.
[QUOTE=Metroid48;19843929]Not sure that it's the best solution, but calling Player:Spawn() and then setting their position & angles back restores the HUD without losing weapons or ammo or anything like that - it might fix the NPC problem too. Not sure if you need to set the health back too.[/QUOTE] Don't worry, I could make it set all back. Thanks for the idea. [editline]08:06PM[/editline] I have a new problem: While spectating I want the player in their position. I mean, you camera is with the misil, but the player keeps in the same position, so anyone can hit you while spectating misile. Any idea?
You mean something like the Nuke pack?
-snip-
[QUOTE=Jackthemaster;19860069]You mean something like the Nuke pack?[/QUOTE] I think so. Like the radio-controlled misile of nuke. While you control it, people must be able to shot you or hurt you by anyway.
Unless I horribly misunderstood something: [b][url=wiki.garrysmod.com/?title=Player.SetViewEntity]Player.SetViewEntity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[QUOTE=_Kilburn;19861891]Unless I horribly misunderstood something: [b][url=wiki.garrysmod.com/?title=Player.SetViewEntity]Player.SetViewEntity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b][/QUOTE] Thank you a lot. There is any snippet code of third person view with SetViewEntity?
[QUOTE=lilezek;19862054]Thank you a lot. There is any snippet code of third person view with SetViewEntity?[/QUOTE] What third person view? As far as I know, you want to spectate the rocket, so all you have to do is set the view entity to your rocket. [lua]function PlayerMT:Spec( ent ) self:SetViewEntity(ent) end function PlayerMT:UnSpec() self:SetViewEntity(self) end[/lua]
I think he wants to follow it in 3rd Person not First as you stated.
[QUOTE=commander204;19863516]I think he wants to follow it in 3rd Person not First as you stated.[/QUOTE] Yup, fallout 3 VATS style.
VAC? You mean VATS xD and well your code should work only thing to change should be: [lua] function PlayerMT:UnSpec() -- self:Spectate( OBS_MODE_NONE ) // No need for this! self:UnSpectate() local pos = self:GetPos() self:Spawn() self:SetPos(pos) end [/lua] Soemthing like that, untested.
Sorry, you need to Log In to post a reply to this thread.