Image on top (Like CoD)

Hi, i’m wondering if anyone knows how to make an image/icon on top of everything like they do in Call of Duty, as shown in the picture below where it says “Capture”. Do anyone have an idea for how to do this?

I don’t know python sadly, but aren’t there like a z-index or something to place the image on top of everything else?


  • Thanks

You can just use an overlay scene (a normal scene that gets added to your game scene as an overlay scene) to draw GUI elements over the game scene. You can also use BGUI to create a GUI system that renders over the screen via the game scene’s post_draw attribute.

you kinda lost me there, sry!

An overlay scene in the BGE is a scene that is drawn over other scenes.

In your example, the overlay scene would be a scene that just has the text “Capture”, and that gets added over the game scene (that has the gun and terrain).

Anyway, just use the Scene actuator to add a scene to your game as an overlay scene.

I have been looking for something similar, it was for a mini-map at first (which I’v figured out, the whole realtime render texture baking or something) but I’ve been trying to take a step further for use on special effect and stuff. I’ll look around for what you mentioned about BGUI, if there is anything you could add to that (a bit more specific), it’d be great @SolarLune.

This video will get you started…

The way in which images can appear to rest above objects is that they’re drawn above the objects in “screen space”.
This means that we determine the position of the object’s pixels on the screen, and then draw the image relative to that position (such as slightly above it). I would do this using BGUI or OpenGL (which BGUI leverages) rather than moving actual game objects. I will try and and create an example.
To get the screen-space position of a GameObject, you can use the “getScreenPosition(object)” method of a KX_CameraObject

Check out the BGE guide to messages in my signature (guides link). It shows you how to implement such thinks.

And yes an overlay cene will be rendered above a background scene.

Thanks, please pm me if you get good results with your example, cause i’m not good with python. PS. i’m using 2.49

You might be better using an overlay scene with the same camera position and settings. It will be easier for you than Python.

Yeah but as they camera moves how would i make it move in the HUD scene? so that both cameras have same world position? this can be done with python right?

Sure it can.

Attachments

example.blend (85.8 KB)

Can the script be implemented to work in 2.49?

Yes, but why work in 2.49?
It has long since been dropped as the official release.


import GameLogic as logic


def register(cont):
    own = cont.owner
    logic.globalDict.setdefault("cameras", set()).add(own)
    
def broadcast(cont):
    own = cont.owner
    
    for obj in logic.globalDict.get("cameras", set()):
        obj.worldPosition = own.worldPosition
        obj.worldOrientation = own.worldOrientation

Thanks, but how did you set this up? The camera from the background scene will have the Python module with “overlay.broadcast” and the hud camera with the python module “overlay.register” triggered by an always sensor? and then ofc adding the overlayed scene which in this case is “Overlay”

The module overlay.register registers a “listener” camera, which will be synchronised to the broadcast camera
The module overlay.broadcast iterates (or goes through each camera in) the camera list and sets the position and orientation to that of the broadcast camera (the object running the script). The listener logic is run once, when the overlay scene is added. There is also some track to logic on the Text object, and I changed the tracking axis to Z, and the up axis to Y

Okay, cause i did a quick test but seems like i couldn’t get it to work in 2.49 with the new script, i’ll try again later.

Can’t get it to worK! :confused:

I would advise using Blender 2.6 to avoid these problems in future.
test.blend (173 KB)