Camera Issues

Okie dokie so Its a fairly simple scene, I have a character standing there and I want the camera to be facing him at all times, but I want to be able to zoom in and out with the scroll wheel, and be able to click the right mouse button and drag to move the camera around the character… how do I do this =.=

I’ve got just the code that you need. ('Tis not mine)

import Rasterizer
import GameLogic
import math
cc = GameLogic.getCurrentController()
cam = cc.getOwner()

w = Rasterizer.getWindowWidth()
h = Rasterizer.getWindowHeight()
mouseSensor = cc.getSensor("mouse")
x = mouseSensor.getXPosition()
y = mouseSensor.getYPosition()


rho = cam.rho
theta = 2.0*pi * (w-x) / w + pi
phi = 0.65*pi * y / h

a = pi - theta
b = 0.0
g = phi

# center is at [0,0,.5]

camPos = [rho*s(phi)*s(theta), \
          rho*s(phi)*c(theta), \
camOr = [[c(a)*c(b), c(a)*s(b)*s(g)-s(a)*c(g), c(a)*s(b)*c(g)+s(a)*s(g)], \
         [s(a)*c(b), s(a)*s(b)*s(g)+c(a)*c(g), s(a)*s(b)*c(g)-c(a)*s(g)], \
         [-s(b),     c(b)*s(g),                c(b)*c(g)]]


Oh yah, setup…


Wow thats what I call service. another noob question, how do I get it to work =.= I thought I just put it in the text box and tell it to run python script but it says it dosnt work.

Did you include the .txt or .py at the end? I always screwed that up when I started BGE!

Look at the image, did you add all the blocks?

TT: whos script is it, do you know? can we use it freely without stepping on someone?

Sounds like fun…waiting

Hehehe yeah I’m pretty new to BGE… :confused: its still not working I’m not sure what I’m doing wrong, heres a screen cap:

edit reply to itirx: I cant get the blocks because if I type in it dissapears immedetly

Ok, but the script you are showing has an error, did you look in the console and see what it said?

Also, when you copied the script, and put it in a file what did you name it? If the name wont stay there its because it doesnt exit.

So you must be typing the name wrong? watch the caps, and spaces, etc.

sorry I didnt mean to imply you didnt know the GE, its just that somtimes I get excited when I get an answer here and forgot some of the pieces when I implement it!

O K , I think I’ve gotten everything right but the camera still doesn’t want to do anything. :confused:

I cant see all your logic blocks and properties to dble check? Do you still get an error? if so what is it, the short version, lol.

Name your first mouse sensor “mouse,” then it should work…

? there in the image I just posted… :confused: when I look at the other blender box the DOS looking thing it says: importerror: no module named rasterizer, when i try to run the python script. I see nothing wrong with my logic bricks but when I run the game engine they dont do anything :confused: named first one “mouse” still doesn’t work

OK, I cant do anymore tonight. I will do a demo with a cube and camera and the script, but I cannot do it tonight, its too late me. Sleepy.

TT may come through again tonight, and help.

I dont know enought py, either. But it should find the rasterizer module. Do you have the python for the blender you are using installed? I mean the full python, not the one that comes with blender.

you know 2.4 with 2.4, 2.45 with 2.5 ? the new 2.45 includes the full python though I think.

Also, what line does it say the error on? I think you may have to add the ‘stuff’ at the beginning of the script, the get.owner stuff? LOL

got python 2.51 says “checking for installed python… got it!” when I start. rasterizer still not found

So it doesnt say what line in the script? usually an error says on line __ etc.

upload the blend. if you dont want everyone to have a copy of it, pm me the link, ok?

Dont know why you set it up to play, you just waste my time to open it properly.

You have an error, read what it says. Its on line 10. Check your spelling for the sensor called mouse.

Then run it, you will get another error to fix. Its the same kind of error as above.

Thats a pretty cool script, yet when I zoom in, it doesnt zoom back out, lol.

do we have a Katamari fan present:D

heheheh guilty of being a katamari fan

okie dokie It didnt work the first few times but now it dosnt seem to have issues with line 10. now it says it has issues with line 18 saying "file , line 18 in <module> attribute error: rho I think I could figure this out quite easily except said line 18 says: theta = 3.0*pi * (w-x) / w + pi