Making Head Visible and Invisible

So of course, I’ve made a full body player for my game. I’ve been trying to make the head of my player invisible when you’re in first person but visible when you’re in third. I’m also going to make this a multiplayer game so the head will need to be visible when you’re in third person and for other players…

Any help or tips would be appreciated…

So say you press 1 for first person and 3 for third person. When you press those have it send a message to the head to be invisible if you press 1 and visible if you press 3.

Would this work for a multiplayer game? I’m sure there’s another alternative…

Why do you need it to be invisible in 1st Person? Because the head is blocking the camera, which is inside the head? Either:
-Move the camera outwards, outside of the face.
-If it is inside, you can use “Backface Culling” t hide the inside of the face, and because the camera is inside the face, it won’t see the inside.

I know, but some elements of the face kind of appear like nose and the eyes and when I alter them, it kind of damages the appearance.

I feel that it’ll be more convenient for the first person view.

I would also suggest what Nicholas_A said. That is the method I used for my BGMC23 game and it worked very well.

So what would I do for a multiplayer game?

I might consider this idea, but my main concern at this point is multiplayer…

If it were in multiplayer, on remote clients, then you could display different things from one client to the other, meaning:

ClientA don’t see his own head but sees others.
ClientB don’t see his own head but sees others (because the game is running with different object instances from ClientA, because it is not the same computer, so not the same running BGE game)

In case of a split-screen game you could tinker with backface culling (the “rear” of game faces are transparent), or maybe tinker with the player’s camera “clip start”, making sure the distance at which the camera begins to render things starts past your head (thus not displaying the head). The “clip start” is per camera, so the third-person one could have a more “normal” clip start, when the one for your head could be at 1.0BU for instance.

Hope this helps.

So how would you do this?

^ Like this. There are logic bricks controlling the visibility, you might play around with that.

Now if you’re asking for the multiplayer code, I can’t help.
Look for Python socketserver if you really want to dive in.
Its not impossible, but its not easy at all, with no real easy solution for the BGE yet.

Side note: I heard that the “send message” logic brick was sending messages over the loopback network ?
Meaning it is restricted to the host running the BGE, but if its UDP then its rather easy to catch packets and send them to a remote, right ? I’m looking at this huhu.

EDIT: Riiiight so the “network messages” thingy are not actual packets, I got a bit hyped there. Sigh

What kind of multiplayer game are you thinking of?

  • single screen (all players share the same screen)?
  • split screen (same game session, but different viewports)?
  • multi-instance game (each player has an own game session)?

As mentioned by WKnight02 you can toggle visibility with the visibility actuator. You can even do it via Python.

untested code to attach to the head object…unless you are treating the head as a child object.

import math
if (camera.worldPosition - head.worldPosition).length < 0.1:
own.setVisible(0,1)#object.setVisible(boolean for yes or no,boolean for affect children yes or no)

I apologize if you already received a good answer I am just trying to give extremely simple solutions that a beginner can grasp…the code is pretty straightforward, but I just typed it in and have not tested it…you may also just want to make sure the material for the head has backface culling enabled…this or the clipping range should automatically have it not visible…ofc this depends on scale as well…for the clipping.

So what does this script do exactly?

Read it. it is pretty obvious what it does.

I know what it means, but I wasn’t specific so that’s on me…

I’m concerned about this…if (camera.worldPosition - head.worldPosition).length < 0.1:

if the distance between the camera and the head is less than 0.1 units…

Oh, thanks for explaining that. So if it’s less than 0.1 units it won’t appear in first-person view but in third person?

Well the 0.1 is just an example number. you will have to scale it to your scene.

Everybody’s help was much appreciated. I’ll test it out as soon as possible.

Too me it sounds pretty inefficient to constantly check the distance of the camera to the head of the character.

You already know when you want to toggle to what perspective. Switch visibility based on that information should be sufficient enough.