[NS2 CreateEntity] How to spawn an entity in Client VM ?
Katzenfleisch
Join Date: 2014-03-21 Member: 194881Members, Squad Five Blue, Squad Five Silver, NS2 Community Developer
Hi,
I am working on mod and I wonder if there is a way to create entity on Client side only ? In my case I would like to spawn an alien entity which can only be seen and killed by one player (without any perturbation in the server side, for all the other player this one is just shooting at nothing).
I was looking in Utility.lua but CreateEntity is only Server. Any idea ?
Also, if it is possible to render an alien visible to a single marine in the team, this could do the job for what I need.
Thanks.
I am working on mod and I wonder if there is a way to create entity on Client side only ? In my case I would like to spawn an alien entity which can only be seen and killed by one player (without any perturbation in the server side, for all the other player this one is just shooting at nothing).
I was looking in Utility.lua but CreateEntity is only Server. Any idea ?
Also, if it is possible to render an alien visible to a single marine in the team, this could do the job for what I need.
Thanks.
Comments
This is what I found on Weapons/ViewModel.lua
/**
* ViewModel is the class which handles rendering and animating the view model
* (i.e. weapon model) for a player. To use this class, create a 'view_model'
* entity and set its parent to the player that it will belong to. There should
* be one view model entity per player (the same view model entity is used for
* all of the weapons).
*/
==> CreateEntity(ViewModel.mapName):SetParent(??)
But i do not understand really how it should work. For me there are 3 elements
* The ViewModel class (created via CreateEntity)
* The "client only" element
* The player
Should I create a new class from ViewModel, and then call SetParent ? how do I join those 3 elements ?
Thanks
class "YourClassName" (ScriptActor)
function YourClassName:OnGetIsRelevant(player)
return self.forPlayer == player
end
function YourClassName:SetTargetPlayer(forPlayer)
self.forPlayer = forPlayer
end
something like this! you dont need to use SetParent, this would attach the entity to the player, im sure you dont want that. also i dont really understand why you want to derive from view model, it has a very different purpose from what you want
The major problem I have while overloading the OnGetIsRelevant() (like you suggest) is that it is never called.
I have tried the following
function CLASS:OnGetIsRelevant(player)
Print("Is called")
self.forPlayer = player
end
with CLASS equal to Player (or) Marine (or) Fade. (Marine -> Player -> ScriptActor)
I will try later to create a complete new class and see if it work.
self:SetPropagate(Entity.Propagate_Callback)
in OnCreate
Thanks.