≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Non-code query-loop tip
Posted by:
(you are not logged in)
Enter the missing letter in: "Internat?onal"
(you are not logged in)
Text:
[quote][b]veganpete[/b] wrote: This simple 3-part query-loop is at the heart of all my game-nodes (player/enemy/vehicle, etc): It's very difficult to explain what's happening but it's simple to set up, so hopefully it might be handy for some people to experiment with. Obviously I'm happy to explain/help/provide CCB examples as required. Each loop allows conditional control over all events, rather than just triggering an action when an event occurs. There are only 3 "gates" to pass in each of my loops: [b]Events/Variables/Conditions[/b] I usually attach all these loops to folder-nodes called "Controllers" to keep them all in one place and make it easier to copy/paste between nodes. (eg: folders called "Car Controller", "Helicopter Controller", "Missile Controller", etc..) [b]1- When [Event?], then Set [Variable].[/b] When "W" key is pressed, Set Variable "W" =1 When "W" key is released, Set Variable "W" =0 When "S" key is pressed, Set Variable "S" =1 When "S" key is released, Set Variable "S" =0 [b]2- If [Variable?], then Define [Condition][/b] Every Few seconds (5ms): If "W"=0, If "S"=0, Set Variable "Tilt" = 0 If "W"=0, If "S"=1, Set Variable "Tilt" = -1 If "W"=1, If "S"=0, Set Variable "Tilt" = 1 If "W"=1, If "S"=1, Set Variable "Tilt" = 0 [b]3- If [Condition?], then Do [Action][/b] Every Few seconds (5ms): If "Tilt" = 0, Rotate Absolute "Model" 0,0,0, Animated 500ms. If "Tilt" = 1, Rotate Absolute "Model" 0,0,25, Animated 500ms If "Tilt" = -1, Rotate Absolute "Model" 0,0,-25, Animated 500ms [b]What it does:[/b] 1- Whenever an event happens (such as on proximity or when key is pressed/released, etc), Variables are set. 2- Every few Milli-seconds those variables are checked. 3- Only when set conditions are met, the actions are then carried out. *The example above should tilt the helicopter model forwards/backwards only when W or S is pressed, it should not tilt if none of the keys are pressed, or if W & S keys are pressed together. You can use the loops for whatever you like, this is just one example. [b]Examples in my game:[/b] Car/Helicopter/Bike models tilt/lean depending on direction of travel. Car Wheels point in whichever direction the player is steering. Engine sounds change depending which combination of keys are pressed. Steering wheel turns and locks. Music changes depending on if inside or outside a vehicle. Camera automatically changes, depending which vehicle is active. Missile A.I. chooses to follow target or to switch/follow it's own path instead. Different events are triggered depending if player is being attacked or not. Pedestrians choose where to walk next in the City. [b]Why use this instead of standard "on event, do action"?[/b] I found the standard non-code method very confusing/bloated/messy/difficult to edit. The query loop is self-contained, rather than separate actions spread over several different nodes. The query loop waits for conditions to be met before events are carried out. The query loop checks all related variables and conditions in a single process. The loop continually checks for any changes in variables or conditions. Until a specific condition is met, the loop is simply ignored/skipped. The query loop can eliminate common conflicts between variables/conditions/actions. The entire loop can be turned on or off by making the "controller" folder-nodes visible/hidden. Controller nodes can be copied/pasted between nodes and edited/tweaked quickly. Query loops are simpler to manage and understand, rather than creating a complex sequence of events. A single query loop can be used to create either very simple or very complex events. Multiple combinations of action/variable/condition can be included in a single query loop.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact