2
$\begingroup$

I'm making a game where, when a certain even occurs, I want the camera to move up slowly. When triggered, I have the following Python Script for it:

import bge
cont = bge.logic.getCurrentController()
own = cont.owner
if cont.sensors['Hit Cube'].positive:
    start = own.worldPosition.z
    while own.worldPosition.z-start<2:
        own.worldPosition.z +=.1

This works for moving the camera up 2 blender units, but it does not smooth the motion at all. What are some suggestions to accomplish this effect?

$\endgroup$
  • 1
    $\begingroup$ try own.applyMovement() or applyForce also there is damping property $\endgroup$ – Chebhou May 1 '15 at 21:02
  • $\begingroup$ Can you tell me how I would do that? Thanks! $\endgroup$ – Anson Savage May 2 '15 at 23:59
1
$\begingroup$

You could use a function like z=dist*0.5*(1-cos((now-t0)/duration*pi)) which would start out slow, speed up, and then slow to a stop after duration seconds.

$\endgroup$
  • $\begingroup$ Well, that would probably work. It looks like it's a pretty sophisticated setup. What I ended up doing was made a relative action data block that moved it up smoothly. Thanks for the help! $\endgroup$ – Anson Savage Jun 4 '15 at 17:18
0
$\begingroup$

Check the 14th post in this thread : a blenderartist's thread As @Chebhou notes here, this guy @BluePrintRandom uses forces. Forces make the motion smoother as you want it. Velocities also. But in both cases the body needs to be rigid or dynamic as far as I know and then you can use those physics's attributes.

In your exaple, where you move the camera upwards the z-axis, it could happen with something like this: own.worldLinearVelocity.z = own.worldLinearVelocity.z+1 But again check that post, cause I hear it is better to play with forces.

Be careful,when you make the camera dynamic or rigid, you 'll need to kill its gravity if you don't want it to have one.Here's how: blender stack exchange,kill gravity of 1 object

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.