I'm trying to implement (another) Prezi like presentation solution using Blender and the Game Engine.
I've see and replicate Kris's solution here described http://www.youtube.com/watch?v=I3vMSDxmhQw
However this solution doesn't work like Prezi... because it don't stop at each "slide".
So my question is : can we stop the animation at a specific frame ?
The process would be then:
1) press a specific keyboard key
2) (game) animation will start
3) after 24 frames animation stops
4) Hit again the same keyboard....
5) ... the process repeats step 2) and 3)
and alternative (and more powerful solution)
1) press a specific keyboard key .
2) (game) animation will start
3) animation runs until the next Keyframe
4) Hit again the same keyboard....
5) ... the process repeats step 2) and 3)
I guess that Python is the only way to implement it.
As such , any help, recommendation, suggestions , code examples are welcome.
How to move to a frame, with the action of an actuator ?
Moderators: jesterKing, stiv
-
- Posts: 0
- Joined: Wed Mar 20, 2013 1:52 pm
Hi DarthDarth_Revan wrote:Can you be more specific? Do you just want to have an action actuator start end on specific frames?
thanks for your reply.
In the meantime , I've take a "crash course" in using python with BGE and found a solution for my problem

Basically I used the "normal" : sensor->controller->actuator associated with the camera.
Then associated a property to camera to hold the current slide.
So, now I'm able to move back and forward to a slide by "playing" the animation...or just by jumping to the specific frame.
I can "emulate" Prezi doing the animation or PPT by jumping to a slide.
Since bpy lib isn't available in bge I can't access the keyframe ... so I'm updating these frames manually.
During my quick learning process I realize that in order to animate other objects than the camera I need also to create sensor->controller->actuator for those object and associate the same keyboard key.
Probably there's more optimized ways to do this.
But, hey, this was my first python script

thanks again for your reply and interest.
#
#----------------------------------------------------------------
#
Code: Select all
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
pull = cont.actuators["MoveCamera"]
# get the scene
scene = bge.logic.getCurrentScene()
## Get Camera
#import bpy
#ob = bpy.data.objects["Camera"]
## Get Camera Animations Curves
#ob_act = ob.animation_data.action
## Get Camera Animation first curve
#curve = ob_act.fcurves[0]
points = []
##Get all keyframes points :
#for key in curve.keyframe_points :
# frame, value = key.co
# points.append (frame)
points = [0,60,120,180,240,300,360,420,480,540]
LastSlide = len(points) -1
# get an object named 'Camera' in Game Engine
obj = scene.objects["Camera"]
# get property name "CurrentSlide", which will old the keyframe id
CurSlide = obj["CurrentSlide"]
# Check if left arrow or space or click was pressed -> move forward
if cont.sensors["RightArrow"].positive or cont.sensors["space"].positive or cont.sensors["LeftClick"].positive :
#if we didn't reach the last keyframe/slide, then move forward
if CurSlide < LastSlide :
pull.frameStart = points[CurSlide]
pull.frameEnd = points[CurSlide +1]
cont.activate(pull)
obj["CurrentSlide"] = CurSlide + 1
elif cont.sensors["LeftArrow"].positive :
#if we are't in the first last keyframe/slide, then move backward
if CurSlide > 0 :
pull.frameStart = points[CurSlide]
pull.frameEnd = points[CurSlide -1]
cont.activate(pull)
obj["CurrentSlide"] = CurSlide - 1
elif cont.sensors["UpArrow"].positive :
#if we are't in the first last keyframe/slide, then move backward
if CurSlide > 0 :
pull.frameStart = points[CurSlide-1]
pull.frameEnd = points[CurSlide -1]
cont.activate(pull)
obj["CurrentSlide"] = CurSlide - 1
elif cont.sensors["DownArrow"].positive :
#if we didn't reach the last keyframe/slide, then move forward
if CurSlide < LastSlide :
pull.frameStart = points[CurSlide+1]
pull.frameEnd = points[CurSlide +1]
cont.activate(pull)
obj["CurrentSlide"] = CurSlide + 1