Randomize Object Position

Hello Everybody,
I’m very happy to be aboard!

I have a question for you more advanced folk.

I’m making a screensaver using the GE, basically a rotating object, and I would like to change the camera angle randomly every once in a while after a camera fade.

What I’ve thought out so far is the following - A track-to constrained camera with a black plane parented in front of it is my cam. I use an IPO animation of the plane’s Alpha to make the fade in and out, but what I’d like is to have the camera jump to a random (limited of course) point around the object for a fixed amount of time after a random delay. The camera should change position right after the fade out is completed, and after a slight delay - fade in.

So, my logic is as following:

Timer ends random countdown -> Triggers plane fade (15frames ex.) -> end of fade animation triggers camera position -> camera new position triggers delay (50frames ex.) -> delay end triggers fade in -> random timer starts countdown -> repeat


I don’t know if this can be accomplished with the normal sensor-actuator interface or i have to code it in Py? I hope so :confused:

So far I have figured out some of the points of the game logic, and worked with some actuators, but i need help.

So, Blender Pros, can you crack your knuckles and offer some assistance to a newbie?


Is this the wrong forum to ask?

This is the right forum, yes.

You will need python, yes :slight_smile:

import GameLogic
cont = GameLogic.getCurrentController()
object = cont.getOwner()
x = 1
y = 2
z = 3
# you can change x, y, and z to whatever you want, even make it random...
object.setPosition([x, y, z])

Ok, set up the camera with a delay sensor, and set it to repeat. Enter in your position switch delay time, and plug it in to a python controller which links to whatever you call the script I just wrote for you. Tell me if you have any problems. :slight_smile:

Woot, thanks!

I`ll test this out tomorrow and post what i come up with! =)

Thanks for answering my prayers =)

you can do this without python.

Set up an IPO that rotates the camera around the object. Do it in a way that the IPO contains all positions you want to have. E.g. builds a spiral (is this the right word?) around the center.

Add an int property “randomFrame” to the camera.
Add a sensor that detects that a new camera positon should be set.I think it is your delay sensor or whatever you have.
Connect this sensor with an AND controller to a random actuator. Set “int uniform” mode with min = 1 and max=lastframe of your IPO, the property = “randomFrame” from above.

Add an always sensor (no true pulse, no false pulse).
Connect this sensor the another AND controller. Connect this controller to an IPOactuator in property mode. Set Prop (not frameProp) to “randomFrame”.


What will happen?

  1. The IPO actuator will be activated at the game start. It positions the camera to the position/orientation of the IPO that is defined by the frame that is in the property “randomFrame”.

  2. If your delay sensor goes true, the random actuator calculates a new random value for randomFrame.
    Because the property randomFrame changed its value, the IPO actuator sets the camera to the new position/orientation. It will remain here until the property gets another value.

With this method you can set preferred positons (by setting more frames at this positions) or exclude positions by not setting these positions.

I hope it helps.

Yeah I guess Monster’s method might be a little better, but then again you won’t be able to have every single possible position available to randomly move to…(I would use his method anyways)

use monsters version its better.

Thanks, I’d use Monster’s version i believe, it seems more elegant and more the way “i would do it =)”.
However, It’d be pretty hard to make an animation that would vary the distance from the camera target as well, but maybe I can just adopt the scene to that.

I will try mokazon’s thing as well, and I’ll let you know which worked out better for me!
Thanks! :eyebrowlift: