controling camera with the mouse

i’m looking for a way to rotete an object by moving a mouse (the camera is parented to that object), but there is only “mouse move” and no “mouse move right”, “mouse move down”…and so on…can you provide any assistance?

This requires a pythin script.
Please, serch the forum for simular questions before you ask them.
I am sure this has been covered a million times.

No, it really hasn’t. NOTHING ANYWHERE says how to do it, only gives examples. Examples don’t teach anything. They haven’t helped me, and I’m almost to the point of using a commercial engine for my game. This question has been asked a million times and always gets the same, unhelpful answers.

Erm…sorry for the rant.

I wish I could help you, buddy. Every script I’ve tried doesn’t work with my setup, and there’s really nothing that tells you how to write them. I suggest trying to look at some examples, maybe you can get something out of them that I can’t. Some can be found in the threads pinned in this forum.

-Kato

Once and for all, if you’re serious about making games, learning about 3-D math is a must. But I’m not the one to teach it to you… I don’t know much myself anyway…

But, I made a mouse script just recently. I finally understood rotation matrecis enough to program one.

But it works like a head attatch to a body, so the ‘head’ is above the rest of the ‘body’. So they run different but similar scripts. Here they are:

This one runs on the ‘body’ object, the one that turns left and right. The object running this script needs four properties, Pitch, Yaw, and Sensitivity, all floats, and LastFrame, a timer:


# Look.py

import GameLogic, Rasterizer

Controller = GameLogic.getCurrentController()
Owner = Controller.getOwner()

if (Owner.PlayerControl == 1):
	MouseMove = Controller.getSensor("MouseMove")
	midx = Rasterizer.getWindowWidth()/2
	midy = Rasterizer.getWindowHeight()/2
	Rasterizer.setMousePosition(midx, midy)
	
	deltax = midx - MouseMove.getXPosition()
	deltay = midy - MouseMove.getYPosition()

	dt = Owner.LastFrame # Time passed to this frame. Used for smoothness (or choppyness)
	Owner.LastFrame = 0
	
	zrot = -Owner.Sensitivity * deltax * dt / 12
	xrot = -Owner.Sensitivity * deltay * dt / 12

	## PITCH Modify X-Axis direction
	Pitch = Owner.Pitch - xrot + Owner.Recoil
	Owner.Recoil = 0
	if (Pitch > 85):
		Owner.Pitch = 85
	elif (Pitch < -85):
		Owner.Pitch = -85
	else:
		Owner.Pitch = Pitch

	## YAW Modify Z-Axiz Direction
	Yaw = Owner.Yaw - zrot
	if (Yaw > 180):
		Owner.Yaw = Yaw - 360
	elif (Yaw < -180):
		Owner.Yaw = Yaw + 360
	else:
		Owner.Yaw = Yaw

This one also goes on the main ‘body’ object:


# ZOrient.py
import GameLogic, math

Controller = GameLogic.getCurrentController()
Owner = Controller.getOwner()

zrad = Owner.Yaw / 180.0 * math.pi

Owner.setOrientation(
[[math.cos(zrad), -math.sin(zrad), 0.0], [math.sin(zrad), math.cos(zrad), 0.0], [0.0, 0.0, 1.0]]
)

This one runs on the head, which is probably the camera. It turns up and down:


# XOrient.py

import GameLogic, math

Controller = GameLogic.getCurrentController()
Owner = Controller.getOwner()

xrad = Owner.getParent().Pitch / 180.0 * math.pi

Owner.setOrientation(
[[1.0, 0.0, 0.0], [0.0, math.cos(xrad), -math.sin(xrad)], [0.0, math.sin(xrad), math.cos(xrad)]]
)

Yes, I just want to show off the stuff I make, but if it helps, then that’s even better.

So save all of those to python files. Open up notepad (or your equivalent text editor), and save each one separately as Look.py, ZOrient.py, and XOrient.py. Then open up Blender’s text editor in your game and load up each file into it.

Hook the first two on the Main object up to a Mouse Move sensor with true pulse mode (or not, I can’t remember). The scripts go into the controller.

Do the same for the last script, but on the head (usually the camera parented to the body).

If it doesn’t work for you or you have trouble hooking it up, I’ll try and help…

I’ve tried what you suggest with your scripts, but once I run everything the camera gets stuck looking inside the body object and will not turn. I you could supply a .blend file (for blender 2.37a) that has this setup and working, I’m sure everyone would appreciate it and could use it as a template for there games! I have used an .blend file for games in the past, but it isn’t compatible with the new blender engine. If you could supply a .blend file compatible with the new blender we’d all be VERY VERY appreciative!!! Thank you!!!

As far as I know, mouseover is still broken in 2.37a.

Here you go guys! Here’s a script written by z3r0_d (Nick Winters) I found on the forums at blender.org! It works with the newest version of Blender!!! Enjoy!!! I know I will!!!

The controls are as follows:

W,A,S,D - movement
E - was to open doors (but I erased other objects in scene)
SPACE - jump

Here’s my link:
http://checkoutdahl.com/blendfile/FPS_CO~1.BLE1