Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

blender fps tutorial part 4

Loading...

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

Uploaded by on Jul 10, 2009

Well this is part 4 of my blender tutorial on how to make an advanced fps game. Enjoy and im sorry about the lagg.
get python here:http://www.python.org/download/releases/2.6.2/
script:
######################################## ##############
#
# 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 ###############

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (kiychane01)

  • i looked at all this shit and it didnt work.

  • @DEADDUCKGAMES There will be an update soon that will work... sorry for the inconvenience...

  • TIP:

    on ur desktop to make icons smaller in vista CTRL+mouse wheel

    hope it helps

  • @rokyfox yes it did, thank you soooo much

  • Shaders not supported!

    Python error compiling script - controller " cont#CONT#1":

    File "Freelook", line 51

    pos = mouseMove()

    ----^

    (Those 4 dashes aren't there, I'm just not sure if youtube can format comments properly) Does anyone know what this means?

  • the script is missing some enters and some tabs so it dont work

see all

All Comments (41)

Sign In or Sign Up now to post a comment!
  • sound is soooo of in the tuts!

  • pastie DOT org/3425476

    Replace the dot with a .

  • When I hit P it will not let me look a round

  • wait, so... where's the right script???

  • your voiceover is out of sync with the video by about 10 seconds fast. please fix,

  • do u know how to transfer and object from one scene to another? not in the game but in the editor. Oh and also, i tried out import rasterizer in python idle, it dosnt work.

  • do u know how to transfer and object from one scene to another? not in the game but in the editor.

  • how to make a crosshair

  • @stupidstormy36 could i pleash have it?

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