Questions on Entities

I have a couple questions on how entities work.

First how do inputs and outputs work for entities. I want to be have entities on the map that when the player touches them that they disappear for that player and update a list in the players class. How would I go about doing that.

Second question is that Is it possible to Spawn and Entity at a specific place in C# and can I spawn a player at a specific position. If I can do this how do I do that.

2 Likes

You could create a class based on PhysicsBase and override the OnTouch (I think) function and check if the object is the player, then do whatever you want.

Yes, you can spawn any entity you want and move them anywhere you want. The player can be any entity but the BasePlayer class has a function for respawning

2 Likes

How would one hide an Entity from certain players e.g. if a player OnTouch a entity I want them to not see that entity but everyone else to.

Im not sure if there is a Entity Hide function yet but if there was Id use that, Another way is you could make a method that sets the players playermodel to an invisible model. You are either asking the engine to alter the appearance of an entity or asking the players appearance to change via model swap out, In your case the swap is applied when something happens ( touch )

There’s the EnableDrawing and EnableAllCollisions properties, you can use ClientRPC with only a single client as target to hide it

What do u mean ClientRPC? Is this clientside player code?

Add the [ClientRPC] attribute to a method and make the class partial, the code generator will generate a method with the same arguments and a To type argument. You can only call if you’re the server, calling it with the To argument will call it on that client’s game. For your case you’d probably want to do it something like this HideEntity(To.Single(other)).

HideEntity is a function I would have to write?

Correct, it would have the [ClientRPC] attribute

Oh my bad I mean hideentity is not a function that currently exists correct?

Yes, you’d have to write it yourself