Blender movement tutorial (Look with mouse)

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
9,875
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Sep 29, 2008

NEW LINK DOWNLOAD
http://www.mediafire.com/?c211g2hqev6es5r

http://www.youtube.com/watch?v=YC3nuXY8ZRg don't wear fur, please

I hope this helps.. Good luck with blender everyone

######################################################
#
# MouseLook.py Blender 2.45
#
# Clark R Thames
# Released under Creative Commons Attribution License
#
# Tutorial for using MouseLook.py can be found at
#
# www.tutorialsforblender3D.com
#




######################################################


########################### Logic Bricks

# Get controller
controller = GameLogic.getCurrentController()

# Get sensor named Mouse
mouse = controller.getSensor("Mouse")




# Get the actuators
rotLeftRight = controller.getActuator("LookLeftRight")
rotUpDown = controller.getActuator("LookUpDown")




############################## Need the size of the game window

import Rasterizer

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




############################### Get the mouse movement

def mouseMove(): # distance moved from screen center x = width/2 - mouse.getXPosition() y = height/2 - mouse.getYPosition() # intialize mouse so it doesn't jerk first time if hasattr(GameLogic, 'init') == False: x = 0 y = 0 GameLogic.init = True return (x, y)

pos = mouseMove()




######## Figure out how much to rotate camera and player ########

# Mouse sensitivity
sensitivity = 0.0020

# Amount, direction and sensitivity
leftRight = pos[0] * sensitivity
upDown = pos[1] * sensitivity

# invert upDown
upDown = -upDown


######### Use actuators to rotate camera and player #############

# Set the rotation values
rotLeftRight.setDRot( 0.0, 0.0, leftRight, False)
rotUpDown.setDRot( upDown, 0.0, 0.0, True)

# Use them
GameLogic.addActiveActuator(rotLeftRight, True)
GameLogic.addActiveActuator(rotUpDown, True)


############# Center mouse pointer in game window ###############

# Center mouse in game window
Rasterizer.setMousePosition(width/2, height/2)

For the MouseLook.py
http://www.fpsfiles.tk/

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 5 dislikes

Link to this comment:

Share to:

Uploader Comments (punkstoper)

  • dont work, i do whit the video 3 times but doest work (sorry for my english, im spanish)

    i do not understand, there are an error in the scrypt?

    i use blender 2.49 b

  • @arc575david

    The only thing I can think of is you dont have the right version of python?

  • doesnt work!!!!

  • @Roman8880 there are a few things I cant think of at the top of my head.

    1) you may not have the up to date version on Python

    2) you are using a different version on Blender

    3) you may have made a small mistake during it.

  • how i put a limit on rotation?

  • @sanfelipe007 Sorry mate, not a clue. I am not a Python Programmer, I just found this code on the internet. I recommend asking on blenderartistforum I am sure you will find an answer there

see all

All Comments (63)

Sign In or Sign Up now to post a comment!
  • Nice tutorial, thnx helped a bunch =) good work

  • @sydneydoc i will search thank you :D

  • @sanfelipe007 ,

    There's a couple of sample blends that you can download to do this based on: # get parent z axis vector parentZ = [parentOrient[0][2], parentOrient[1][2], parentOrient[2][2]] # create parent z axis vector vec2 = Mathutils.Vector(parentZ) # find angle between two angle = Mathutils.AngleBetweenVecs(vec­1, vec2)

  • @punkstoper

    i use python 2.7.2

    i downloaded last day

    who python version use you?

    i going to try whit python 3.2.1

  • When I press play it doesn't work and the error is at line 51'' pos = mouseMove()''.

    Somethng is wrong with this line!!!

  • Wow why can't blender just make a way to not need a script for this?

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more