Video playback script problem

hay again
so i posted a thread like this last year about a video script : Script problem - #3 by alf0
and sadly i am back for help on 2 subjects for my current projects

#import 
import bge
from bge import texture
from bge import logic

cont = logic.getCurrentController()
obj = logic.getCurrentScene().objects["game ending screen"]

if not hasattr(logic, 'video'):
	#matID = texture.materialID(obj, "moon_rotation.avi")
	logic.video = texture.Texture(obj, 0) #Take the first material, don't care about the name
	movie = logic.expandPath('//SG ending.mp4')### put the vidow name in the brakets
	logic.video.source = texture.VideoFFmpeg(movie)
	logic.video.source.scale = True
	logic.video.source.play()
    
logic.video.refresh(True)



#video       string  moon_rotation.ogv
#material    string  material
#loop        boolean check


use the property string in the script section movie = logic.expandPath(‘//’+own[‘property_video_name’]) by changing the video file name property, you can upload the videos you need to play and make the movie variable either global or just a variable None - movie = None before starting the script body, then when assigning a new one the variable of the video file name will be overwritten, which will make it possible to start a new video

--------1
i asked for a video script that can enables me to play a video on bge 2.79 and i had one :
but the problem is that it only plays the video once ! if the plays another video or the same one even in another scene it gives me an error message " memory is fried " or something !
what i want is to have a way to run a video on the beginning of my project , thin when you start the game and when you end the game !
meaning that this script cant help me !
so i need help on that !

------ 2
i am using a line on bge to make the camera follow the players in the level

--------obj.worldPosition.x=own.worldPosition.x---------

but it makes the camera follow the player constantly , what i want si a way to have the camera follow the player with a smooth movement or a draag movement .

what type of line should i use for that !!

2:
Solution 1 (with Vector and lerp):

import bge
from mathutils import Vector
scene = bge.logic.getCurrentScene()
Player = scene.objects['Player']
Camera= scene.objects['Camera']

#get Target target with only x:
Target=Vector([Player.worldPosition.x,Camera.worldPosition.y,Camera.worldPosition.z])
# lerp:
drag=0.1
Camera.worldPosition=Camera.worldPosition.lerp(Target,drag)

Solution 2 (with float lerp function):

import bge
scene = bge.logic.getCurrentScene()
Player = scene.objects['Player']
Camera= scene.objects['Camera']

def float_lerp(a, b, f): 
    return (a * (1.0 - f)) + (b * f)

drag=0.1
Camera.worldPosition.x=float_lerp(Camera.worldPosition.x,Player.worldPosition.x,drag)
1 Like

hay thank you so much for your answer !
sorry for taking long
thats great … the scripts works great . only it dosent follow the player on the Z axis !
i tryed to make that up , but it seems complicated .

also if anyone can help me with the video script ! that would be great !!

No, it only follows on the x-axis like your short snippet.
But you can easily edit the first solution so the composed Vector also includes the z-axis of the player:

Target=Vector([Player.worldPosition.x,Camera.worldPosition.y,Player.worldPosition.z])
Camera.worldPosition=Camera.worldPosition.lerp(Target,drag)

If you want all axes then you wouldn’t need the composed Vector at all:

Target=Player.worldPosition
Camera.worldPosition=Camera.worldPosition.lerp(Target,drag)

Or in Solution 2 you just could add a line for the z-axis:

Camera.worldPosition.z=float_lerp(Camera.worldPosition.z,Player.worldPosition.z,drag)

About the video problem I’m just to lazy to create a scene blend for easy testing. Perhaps others will do it.

1 Like

ok … now i get it … i will check it out !!!
thank you so much !!!

ok @musikai this worked so great ! thank you so much !
i can say that problem 1 is sloved now i need to solve problem 2 !

1 Like