Help with making a mouse game - Character movement + Controlling objects

Hello everyone. I am fairly new to both Blender and Python, but not so much to game creation itself.
Currently I am using Blender 2.49b to create a project I need to get done within a month from now. I was using 2.54 before, but I switched to 2.49b since there were so many more tutorials on that and it seems a bit more stable than 2.5x.

I have several questions regarding a game I am trying to make that I don’t have too much time to do, so I am thankful to anyone who can help me out, especially anyone who can help me fast.

The game I am making is a 3D game that only uses the mouse. What want to be able to do is have the character run around a room, suck up objects and spit them out all usng the mouse. So you run around based on the position of the mouse, right click to go into the sucking up stance with a camera closer to the character than just walking around, and left click to actually suck in objects, then once you have an object sucked in, do the same to spit it out. I want to be able to do this for most non-static objects.

Anyway, right down to business. My biggest two problems at this point are two of the things that I definately need in order to finish the game. The movement and the sucking in of objects.

First of all the movement I want to be simply by where the mouse is placed. If the mouse is over top of the character (who is in the center of the screen) the character will not move, but if the mouse is above the character on the screen he will run forwards, to the right of the character he will run to the right and have the camera spin to follow. Basically I need to be able to have the character move 360 degres based on the placement of the mouse pointer on he screen, but I have not yet figued out a way to properly do this. I have seen some tutorials on moving the camera with the mouse and think there may be a way to use that to move the character as well, but I haven’t figured it out yet. If anyon has a good way or a sample or tutorial to do this, please let me know.

The next problem is the sucking in of objects. Again this will be heaving involving the mouse’s position. Sort of like a tractor beam from where the mouse is pointing to the character’s position. Also being able to look around with the mouse before choosing the object you want to suck in.

Perhaps not the most simple requests, but I am sure there is someone here who must be a Blender & mouse expert who can help me out or point me in the right direction.

A big thanks to anyone who can help!

You’re going to have to learn Python. You’ll use Python to get the angle between the player and the mouse position, acquired from a mouse sensor, or the built-in logic.mouse variable (I think). Then, rotate the character to face that angle. If the distance between the player and the mouse position is less than 1 Blender unit, for example, then don’t allow the player to move.

or use an empty at the position of the mouse hitposition then track the player to the mouse

@Joeman16
Python doesn’t seem to be too different from some of the programming languages I have studied, but still has some things I don’t really get about it yet, it might take a while to come up with an original code for that. If someone already has some script to do the movement or the sucking in it would make things go a lot faster.

@agoose77
I think I would still need the mouse to be recognized in 3D space in that situation, but perhaps it would be possible to do the movement using an empty that follows the mouse only referencing the two angles.

i have a script im using for a game im making that lets turn left and right in full 360 degres.

import Rasterizer

import Rasterizer

get controller

controller = GameLogic.getCurrentController()

get the object this script is attached to

player = controller.owner

Get sensor named Mouse

mouse = controller.sensors[“Mouse”]

Get the actuators

lookLeftRight = controller.actuators[“LookLeftRight”]
lookUpDown = controller.actuators[“LookUpDown”]

get width and height of game window

width = Rasterizer.getWindowWidth()
height = Rasterizer.getWindowHeight()

define mouse movement function

def mouseMove():

# distance moved from screen center      
x = (width/2) - mouse.position[0]
y = (height/2) - mouse.position[1]
  
# intialize mouse so it doesn't jerk first time
if player["mouseInit"] == False:
    x = 0
    y = 0
    # bug in Add Property
    # can't use True.  Have to use 1
    player["mouseInit"] = 1
  
# return mouse movement
return (x, y)

get mouse movement from function

move = mouseMove()

set mouse sensitivity

sensitivity = 0.0020

Amount, direction and sensitivity

leftRight = move[0] * sensitivity
upDown = move[1] * sensitivity

set the values

lookLeftRight.dRot = [0.0,0.0,leftRight]
lookUpDown.dRot = [upDown,0.0,0.0]

Use them

controller.activate(lookLeftRight)
controller.activate(lookUpDown)

Center mouse in game window

Rasterizer.setMousePosition(width/2, height/2)