intruder on 4/5/2011 at 21:54
Before going into any details, I want to sum up what vehicles created with this tutorial
can do and what they
can't do.
There are possibly other, maybe even easier means to get a vehicle moving in DromEd. This is just my idea of getting it work!
The proposed solution offers:
- free control over the vehicle (all 3 axes)
- collision detection with objects and solid terrain
Limitations:
- vehicles can't be used on uneven terrain (only angles near 90° work)
- vehicles move with constant velocity
- vehicles can't turn, but they can move sidewards instead
Therefore, this tutorial is best suited for constructing:
- submarines
- motorboats
- cranes
- airships
- balloons
The following 4 steps are required to build vehicles with DromEd:
1. Create a free controllable vehicle
2. Attach the player to the vehicle
3. Prevent unlimited acceleration
4. Enable collision with objects and terrain
1. Create a free controllable vehicle1. Download and install tnhScript ((
http://thiefmissions.com/telliamed/tnhscript21.zip) download)
2. Load tnhscript into your mission
3. Create an arbitrary physical object, e.g. a HugeCrate and call it "Vehicle"
4. Create two markers somewhere in your level (you need two markers for each axis; we will only add sidewards movement for the sake of simplicity)
5. Give each marker the (
http://dromed.whoopdedo.org/tnhscript/trapmoverelative) TrapMoveRelative-script
6. Select one marker, name it "Left" and add the following property "Editor -> Design Note: dx=10"
7. Select the other marker, name it "Right" and add the following property "Editor -> Design Note: dx=-10"
8. Link both markers with your vehicle via
ControlDevice9. Create two buttons, name them "Button_Left" and "Button_Right", and link both to your vehicle via
PhysAttach10. Link "Button_Left" via
ControlDevice to the marker called "Left"
11. Link "Button_Right" via
ControlDevice to the marker called "Right"
If you now start the game, you will be able to control your "vehicle" by pressing the buttons.
2. Attach the player to the vehicleUse any tutorial for CamVator sequences etc. as a reference how to accomplish this.3. Prevent unlimited accelerationYou might have noticed that you can accelerate the vehicle each time you press a button until you reach Warp 9...
What we want to do now is the following. Each time a button is frobbed, the link between this button and the corresponding marker will be removed. Frobbing the "opposite" button re-creates the link.
We will use conversations to accomplish this.
[the following assumes that you have a blueroom and a conversation AI from Step #2]
1. Create 2 new conversation markers, name one "Conv_Left" and the other "Conv_Right"
2. Create 2 new buttons, name on "Button_MoveLeft" and the other "Button_MoveRight"
3. Remove the
ControlDevice-links from "Button_Left" and "Button_Right"
4. Add a
ControlDevice-link from "Button_Left" to "Conv_Left"
5. Add a
ControlDevice-link from "Button_Right" to "Conv_Right"
6. Add a
ControlDevice-link from "Button_MoveLeft" to "Left"
7. Add a
ControlDevice-link from "Button_MoveRight" to "Right"
8. Create a new quest variable and name it "MoveSidewards", initialize it to "0"
9. Create a new QuestVarTrap, name it "QVar_MoveLeft", add "Trap -> QVar: -1:MoveSidewards"
10. Create a new QuestVarTrap, name it "QVar_MoveRight", add "Trap -> QVar: +1:MoveSidewards"
11. Add a
ControlDevice-link from "Button_MoveLeft" to "QVar_MoveLeft"
12. Add a
ControlDevice-link from "Button_MoveRight" to "QVar_MoveRight"
13. Create a new conversation marker, call it "AddSidewardsMovement" and add the following conversation steps:
Actor: ActorOne
Flags: [None]
Action: Add Link
Argument 1: ControlDevice
Argument 2: Conv_Left
Argument 3: Button_Left
Actor: ActorOne
Flags: [None]
Action: Add Link
Argument 1: ControlDevice
Argument 2: Conv_Right
Argument 3: Button_Right
14. Create a new QuestVarTrigger, name it "DetectNoSidewardsMovement" and add "Trap -> QVar: "0:MoveSidewards"
15. Add a
ControlDevice-link from "DetectNoSidewardsMovement" to "AddSidewardsMovement"
16. Add the following conversation steps to "Conv_Left":
Actor: ActorOne
Flags: [None]
Action: Remove Link
Argument 1: ControlDevice
Argument 2: Conv_Left
Argument 3: Button_Left
Actor: ActorOne
Flags: [None]
Action: Frob Object
Argument 1: Button_MoveLeft
Argument 2:
Argument 3:
Actor: ActorOne
Flags: [None]
Action: Add Link
Argument 1: ControlDevice
Argument 2: Conv_Right
Argument 3: Button_Right
17. Add the following conversation steps to "Conv_Right":
Actor: ActorOne
Flags: [None]
Action: Remove Link
Argument 1: ControlDevice
Argument 2: Conv_Right
Argument 3: Button_Right
Actor: ActorOne
Flags: [None]
Action: Frob Object
Argument 1: Button_MoveRight
Argument 2:
Argument 3:
Actor: ActorOne
Flags: [None]
Action: Add Link
Argument 1: ControlDevice
Argument 2: Conv_Left
Argument 3: Button_Left
If you now start the game, you will notice that your vehicle will move with a constant velocity and pressing the same button more than once has no effect.
4. Enable collision with objects and terrainThe last remaining issue you've most likely already noticed is the lack of collision with objects and terrain. Your vehicle moves straight through everything, which we are going to change now.
What we are going to do now is to add some sensors to your vehicle which are able to detect other objects and walls and stop your vehicle when it collides with them.
We need:
- sensor messages / sensor impulses
- sensors emitting such impulses
- your vehicle reacting on such sensor messages
We will use emitter-traps which will be attached (
PhysAttach) to your vehicle. They emit a constant stream of sensor projectiles, i.e. the
sensor impulses.
To limit the range of each sensor, we are going to destroy the projectile shortly after emitting it. If the projectile however collides with something before being removed, it will send out a sensor message which is then picked up by your vehicle.
1. Create a new stimuli archetype, name it "DirectionStim"
2. Create a new archetype under "DirectionStim", name it "LeftStim"
3. Create a new archetype under "DirectionStim", name it "RightStim"
4. Save the gamesys and restart DromEd
5. Create a new archetype under "physical", name it "Sensors", add the following property:
Renderer -> Render Type: Not Rendererd
6. Create a new archetype under "Sensors", name it "SensorMsg", add the following properties:
Tweq -> ModelState: On, [None], 0, 0
Tweq -> Models:
Halt: Destroy Object
AnimC: Sim
MiscC: [None]
CurveC: [None]
Rate: 100
Physics -> Projectile -> Faces Velocity: TRUE
Physics -> Projectile -> Initial Velocity: 20, 0, 0
Physics -> Model -> Type Sphere, 1, FALSE, FALSE
Physics -> Model -> Attributes -> Gravity: 0%
Physics -> Misc -> Collision Type: Bounce, Slay on Impact
7. Create a new archetype under "Sensors", name it "SensorResponse", add the following properties:
Tweq -> ModelState: On, [None], 0, 0
Tweq -> Models:
Halt: Destroy Object
AnimC: Sim
MiscC: [None]
CurveC: [None]
Rate: 100
8. Create a new archetype under "Sensors", name it "SensorEmitter", add the following properties:
Tweq -> EmitterState: [None], [None], 0, 0
Tweq -> Emit:
Halt: Continue
AnimC: NoLimit, Sim
MiscC: [None]
CurveC: [None]
Rate: 150
Max frames: 0
Emit what: SensorMsg
S -> Scripts: TweqOnOff
Physics -> Misc -> Collision Type: Bounce
9. Create a new archetype under "SensorResponse", name it "LeftResponse", add the following property:
Act/React -> Sources:
Object: LeftResponse
Stimulus: LeftStim
Propagator: Radius [Radius: 32, Flags: [None], Dispersion: None] (Note: the radius depends on the size of your vehicle)
Intensity: 10 [Flags: Destroy Object On Completion, Period: 500, Max Firings: 1, Intensity Slope: 0]
10. Create a new archetype under "SensorResponse", name it "RightResponse", add the following property:
Act/React -> Sources:
Object: RightResponse
Stimulus: RightStim
Propagator: Radius [Radius: 32, Flags: [None], Dispersion: None] (Note: the radius depends on the size of your vehicle)
Intensity: 10 [Flags: Destroy Object On Completion, Period: 500, Max Firings: 1, Intensity Slope: 0]
11. Create a new archetype under "SensorMsg", name it "LeftMsg", add the following property:
Links -> Corpse:
From: LeftMsg
To: LeftResponse
12. Create a new archetype under "SensorMsg", name it "RightMsg", add the following property:
Links -> Corpse:
From: RightMsg
To: RightResponse
13. Create a new archetype under "SensorEmitter", name it "LeftEmitter", add the following property:
Tweq -> Emit:
Halt: Continue
AnimC: NoLimit, Sim
MiscC: [None]
CurveC: [None]
Rate: 150
Max frames: 0
Emit what: LeftMsg
14. Create a new archetype under "SensorEmitter", name it "RightEmitter", add the following property:
Tweq -> Emit:
Halt: Continue
AnimC: NoLimit, Sim
MiscC: [None]
CurveC: [None]
Rate: 150
Max frames: 0
Emit what: RightMsg
15. Create an instance of "LeftEmitter" (name it "LeftEmit") and "RightEmitter" (name it "RightEmit") and link both via
PhysAttach with your vehicle
16. Add a
ControlDevice-link from "Button_Left" to "LeftEmit"
17. Add a
ControlDevice-link from "Button_Right" to "RightEmit"
18. Create 2 new inverters, name on "LeftInverter" and the other one "RightInverter"
19. Add a
ControlDevice-link from "Button_Left" to "LeftInverter"
20. Add a
ControlDevice-link from "Button_Right" to "RightInverter"
21. Add a
ControlDevice-link from "LeftInverter" to "RightEmit"
22. Add a
ControlDevice-link from "RightInverter" to "LeftEmit"
23. Add the following 2 receptrons to your vehicle:
Object: Vehicle
Stimulus: LeftStim
Min Intensity: 0 [No Min = true]
Max Intensity: 0 [No Max = true]
Effect: Frob Object
Target Object: Button_Right
Object: Vehicle
Stimulus: RightStim
Min Intensity: 0 [No Min = true]
Max Intensity: 0 [No Max = true]
Effect: Frob Object
Target Object: Button_Left
What happens now is the following:
If your vehicle moves close to a wall, the sensor-projectile will collide with the wall and get destroyed. The Corpse-link creates a sensor-response which sends out his stim. Your vehicle detects the stims and frobs the button, opposite to the current driving direction, thereby stopping the vehicle.
Here is a small test mission to demonstrate a submarine capable of moving to the left, right, forward and backward:
(
http://www.file-upload.net/download-3408592/SubmarineTest.rar.html) Demo (Note: tnhScript 2.1 is required)