StarBlender


StarBlender tut4part2

TUTORIAL 4

GAME BLENDER & PYTHON

2/2

In this part of the tutorial, we add a strand of logic which utilizes the script and demonstrate a possible application for it.

1°) Normally, the logic of the camera is set up as follows:

Therefore, add a String property, Name: "clic" with a value of "off", then:
_ a Mouse sensor, "Left Button" ====> linked to
_ an AND controller ====> linked to
_ a Property actuator; Assign, Prop: clic, Value: "on"
_ a Mouse sensor, "Left Button", Inv ====> linked to
_ an AND controller ====> linked to
_ a Property actuator; Assign, Prop: clic, Value: "off"

Which produces:

2°) Now, the script will work. If you press P to begin Play mode, the Empty (Target) will be placed where you click and this will happen, whatever the position of the camera is (Note: it must be directed downwards). Connect, parent (ctrl-P) any object (Perhaps an IcoSphere scaled down by a factor of 0.3) with the Empty if you want to see something, because the Empty is not visible in Play mode. (Note: If you are using the downloaded file "gbtut4.blend", you may wish to switch to Wireframe display mode [z] so that you can view the object placement properly).
Now, add displacement and zoom features to the camera to see whether the script works correctly, irregardless of the camera's position.

3°) Voila, we are finished! Now, just for the fun of it, create a car with:
_ a Collision sensor, Property: ground and
_ a Near sensor, Property: target (Note: you must add a "target" property to Target, the Empty) =====> with both of the 2 sensors linked to
_ an AND controller ====> linked to
_ a Motion actuator with a very low dLoc value, and
_ an Always sensor ====> linked to
_ an AND controller ====> linked to
_ an Edit Object actuator, Track to OB: Target (the name of the Empty) and a Time value set to at least 30 (the time in frames that it will take the car to turn around towards the target)

Obviously you must add a ground with a ground property and materials with suitable dynamic parameters (to obtain proper movement for the car):

"Fh Dist" is the distance of the action from the ground,
Friction is used to avoid the undesireable sliding action of the car
"Fh Force" is used to force the "Rot Fh" of the car, so that it will follow the curves of the ground.

4°) You should now have a small car which goes where you tell it to! Now you know a little more about the obscure Python. Do not hesitate to study the scripts from other games and also read the documentation provided by Jan Walter at http://www.janw.gothere.uk.com/ Here is my small example file in case you have any problems.

END

StarBlender

Today :
Friday 19 April 2024
Last update : 2001

Blender version : 2.12

Par d�faut

Untitled Untitled Untitled

You think GameBlender is :
without a future.
disappointing.
interesting.
promising.
fantastic.
 

results

©copyright Abjedi 2001