#Bah_CamBug.py v1.2 by gorgan_almighty #--------------------------------------- # #This is a work around script for that #annoying little Camera Actuator bug #in Blender Publisher 2.25 that stops the #camera from following the player up slopes. # #copyright (c) gorgan_almighty # #(real name: Keith Gearty) # #Email: gorgan_almighty@yahoo.co.uk # #This script can be used, distributed, #modified, abducted by aliens, buried in a #time capsule, or printed out and eaten for #lunch as much as you like for all I care #as long as these copyright details remain intact. # #Ummm... Oh yeah this script is supplied 'as is'... #...blah blah blah......... # #Right, down to the important stuff... # #1. How the script works #2. How to get it working in your game # # #1. HOW THE SCRIPT WORKS: #------------------------ # #Ok basically this script uses 2 empties, #'emp1' and 'emp2', to stand in for the camera #and player at sea level (z=0). # #emp2 always copies its x and y coordinates #from the player. Its z coordinate is always 0. #The other empty, emp1, has a camera actuator #trained on emp2. emp1 and emp2 therefore work #the same as the camera and player did before, #theres just no chance of emp2 going up a slope. # #Now, the cameras x and y coordinates are copied #from emp1. The camera is given a property, height, #the height you want it to stay at above the player. #the cameras z coordinate is then set to... # # z coordinate of player + height property # #Lastly, the camera is made to always look at the #player by using an Edit Object actuator and setting #it to 3D track to player in 0 time. # # #2. HOW TO GET IT WORKING IN YOUR GAME #------------------------------------- # #Hmmm... did you just skip the bit above by #any chance? If ya did, please take time to #read it, cos its not hard to understand and #you'll find it helpful in getting this bit #working. # #Ok firstly you'll need to make 2 empties, lets #call them emp1 and emp2. Setup a camera actuator #in emp1 that looks at emp2. Give it the Min and #Max values you want but set height to 0.00 # #Next, select the camera and add a property #called 'height'. Set it to the height value that #you would have put in the camera actuator. # #Next, give the camera an Always sensor with pulse #mode ON and link it to an Edit Object actuator. #Set the actuator to Track To the player (3D on). #Add a python controller, set it to call this script, #and link it to the same Always sensor. # #Now SHIFT+select emp1 then the camera, make sure #'Sel' and 'Link' are both on under Actuators, and #add an actuator to emp1. Now join the camera #python controller to the new actuator under emp1. # #Now SHIFT+select the player then the camera, make sure #'Sel' and 'Link' are both on under Actuators, and #add an actuator to the player. Now join the camera #python controller to the new actuator under the player. # #Now SHIFT+select emp2 then the camera, make sure #'Sel' and 'Link' are both on under Actuators, and #add an actuator to emp2. now join the camera #python controller to the new actuator under emp2. # #--------------------------------------------------- # #Ok that should be it, it should work now. It might slow #the game down a bit more than the camera actuator #originally did but it shouldn't be too bad. The example #blend file that I originally supplied with this should #answer any questions you have(just use the cursor keys #to move around, but if you're still havingtroubles #getting it working or if ya just want to tell me how #great I am :) then post a message to me on the realtime #forum at Elysiun.com # #Ofcourse if you've just dug this script out of a time #capsule 300 years in the future and Elysiun.com #no longer exists, then no trouble you can email me at: # # gorgan_almighty@yahoo.co.uk # #Have fun ppl and keep on BLENDing! # # # #Oh yeah I almost forgot, heres the script....... c = GameLogic.getCurrentController() camOwnr = c.getOwner() actuatorList = c.getActuators() emp1Ownr = actuatorList[0].getOwner() playOwnr = actuatorList[1].getOwner() emp2Ownr = actuatorList[2].getOwner() empXpos, empYpos, empZpos = emp1Ownr.getPosition() playXpos, playYpos, playZpos = playOwnr.getPosition() emp2Ownr.setPosition([playXpos, playYpos, 0]) emp2Ownr.setOrientation(playOwnr.getOrientation()) #This line was a last minute addition, it should work fine but I've only briefly tested it. camOwnr.setPosition([empXpos, empYpos, playZpos+camOwnr.height])