Upbge 0.3 logic nodes for smoothing camera?

In UPBGE 0.3 logic editor i made an fps camera.
The camera is parented to some cube and the cube has the mouse look logic.

Weapons are parented to the same cube, and it’s obvious there is some jittering on weapons movement when turning the camera.
Is there some options to smooth the camera nodes ? Or must this be done in Python ?

for starters, the mouse look actuator is just plain awful and certainly glitches and jitters a lot. secondly, bge-eevee is still very experimental.

i know theres some eevee processing settings that cause a blur type effect?

the cheapest way to smooth something is enable “slow parent”, but thats a pretty ugly hack.

a python mouse look is your best bet.

Slow parent was removed during the transition to the new Depsgraph

When something is parented to camera and when the denoiser is ON (in render tab > sampling > viewport denoising), there are some glitches.
What can be done is disable the denoiser but this will cause issues with antialiasing.
You can try to disable denoiser, and add a custom antialiasing 2D filter (an FXAA filter is in text editor templates).
But in some cases (if you use AO for example), FXAA won’t be enough to have a good image quality. In this case, some custom GLSL 2D filter denoisers can be used, but it is hard to find a good solution when we disable viewport denoiser.
If some users find good glsl filters which can be used to replace viewport denoising option, we could add it to GLSL templates list.
(about slow parent, it was removed in viewport, but i restored it for bge only some time ago).

Oh i didn’t know. It’s great!!!

The effects is more about the weapon beeing always late about parent rotation, making that obvious sort of jittering.
I tried the logic node action “Set Parent”, but this produces the same delay, it’s like parenting on the editor or using nodes has some issues.

Because rotations are based on direct mouse input, it does not look as good as smoothed movement fps games have, so i would also like to add some mouse smoothing.

Could Upbge 0.3 get some new git branch for templates and examples ?
New people appreciate a lot to good starting examples.
Meanwhile i will try to provide some python and blender file for a solid fps.

new people need to use the search function, then will find out there are a lot of mouse or movement or camera scripts around for free in the resource section of this forum.

2 Likes

Any link for a tutorial that works with Upbge 0.3 ?
My goal is to make something smooth like that game
https://www.youtube.com/watch?v=yYPwxY6XiD0
I only need a stable and smooth fps camera and weapon.

ok sorry readed over it, thought v0.2.4. i’m not sure if the scripts are working in 0.3.0

0.3.0 is not a good engine to use right now, i would stick to 0.2.4/0.2.5. V0.3.0 is really in early alpha stage, and a lot of stuff won’t work yet.

Here is my camera script adjusted to work in all upbge versions

#2020############################################
#                                               #
# FIRST PERSON CAMERA SCRIPT ADJUSTED BY COTAKS #
#                FOR UPBGE 0.3.0                #
#                                               #
##############################################V2#

from bge import logic, render
from mathutils import Vector

def camera_look(cont):

    sensitivity = 1.5  # mouse sensitivity
    smooth = 0.6        # mouse smoothing (0.0 - 0.99)
    min = 15            # min camera angle in degrees 
    max = 140          # max camera angle in degrees 
    
    #adjust these, if you don't parent the camera to a 'body/cube' then remove 
    #the .parent from camera_controller
    camera              = cont.owner.scene.active_camera
    camera_controller   = camera.parent

    # center mouse on first frame, create temp variables
    if "oldX" not in camera:
        logic.mouse.position = (0.5,0.5)
        camera["oldX"] = 0.0
        camera["oldY"] = 0.0
    else:
        #in upbge 0.2.4 add -1 after each W,H. 
        #so you get render.getWindowWidth()-1, render.getWindowHeight()-1
        w, h = render.getWindowWidth(), render.getWindowHeight()
        center_x = w // 2 / w # truediv operation
        center_y = h // 2 / h # truediv operation
        x = center_x - logic.mouse.position[0]
        y = center_y - logic.mouse.position[1]
        
        x *= sensitivity
        y *= sensitivity
       
        # Smooth movement
        camera['oldX'] = (camera['oldX']*smooth + x*(1.0-smooth))
        camera['oldY'] = (camera['oldY']*smooth + y*(1.0-smooth))
        x = camera['oldX']
        y = camera['oldY']

        # set the values
        if camera_controller is not None:
            
            camera_controller.applyRotation([0, 0, x], False) # global Z axis left/right

        # get the orientation of the object
        ori = camera.worldOrientation
        
        # create a mathutils vector 1 
        vec1 = Vector([ori[0][2], ori[1][2], ori[2][2]])

        # create a mathutils compare vector 2
        vec2 = Vector([ 0.0, 0.0, 1.0])

        # find angle in radians between two vectors and convert to degrees
        Ang = vec2.angle(vec1) * 180.0 / 3.14159

        # Cap the camera
        if (Ang > min and y<0) or (Ang < max and y>0):
            camera.applyRotation([y, 0, 0], True) # local x axis up/down
       
        # Center mouse in game window
        logic.mouse.position = (0.5,0.5)

FOR upbge 0.2.5 or lower do what i said in the script and add the -1 in order to get the script working as it should.

Thank you.

BTW, objects parenting in editor should perhaps be fixed for animated objects if this is related to Upbge ?
When moving parent with logic the non animated child objects are fine, but animated child objects get lag rotations or crazy deformations happening.
For example some animated character and weapons for an fps game.
In most engines objects in editor parenting is just 100% reliable and stable, whatever moves or rotate the parent objects , animated child objects just follow without any issues.

About Upbge 0.3 , i prefer to use it, to showcase the best graphics Upbge can do to look almost the same as other indie games made on other engines.
And Upbge from 0.3 is the new big thing about a modern and better Blender game engine.

How old is your build?

I think i picked up from the main thread
https://blenderartists.org/t/upbge-0-3-0/1174109
Should i pick up it from somewhere else ?

not sure if this is still a thing, but in bge, the animation system doesnt update the world transforms each frame. it skips over a frame or two of data, wreaking havoc on anything trying to keep track to an animated object.

Last builds are always here: https://mega.nz/#F!t9EEFSaS!JPiOPSInCZyU-SW_-rhEOQ

2 Likes

yeah check in a more recent build - if you have troubles post a video here and then we decide if it needs a bug report

The bug is the same with this build.
The animated child objects has it’s animation becoming incorrectly very deformed when the parent rotates with logic nodes like mouse look.

Download the blend file (windows zip file) and play the game, when moving the mouse to rotate the camera horizontaly the animated object will get it’s animation very glitchy.
https://ufile.io/rt17853z

Yes, this is a bug related to you KX_GameObject::TagForUpdate code which is wrong… We’ll see what we can do.