Monday 7 November 2011

Make a loop to spawn AI automatically


Use "Time:Delay" and "Logic:Any" nodes to spawn AI every second - Of course you can change the frequency in your "Time:Delay" node!

Sunday 23 October 2011

Add Child to an XML file

This FG shows a simple example of adding a child to an XML file. If the xml file doesn't exist yet, it will create a new file; otherwise it will open the file and update. (I just use an UpDownCounter to make up the value for each child). Please notice that if you want to add 3 new children and make it look like:
<root>
<child>1</child>
<child>2</child>
<child>3</child>
</root>

rather than
<root>
<child>3</child>
</root>

you need to open the existing xml file and add child in, not creating new file every time.


The xml file looks like this after 6 updates:

Sunday 14 August 2011

Mouse Input

This flowgraph shows a simple example that you can increase or decrease the height of a box by holding your mouse (hold left mouse key to increase, and right mouse key to decrease). The height increases/decreases gradually as you hold the key; it stops when you release the key.


Sunday 7 August 2011

Click to Move Objects


I’ve just created a flowgraph which moves objects when left click the mouse (to the spot where you clicked on).


1.       When mouse hovers on an object, the outline of object will be silhouetted [HUD: SihouetteOutline];

2.       At the meantime, it shows message “You are about to move XXX (Name of Object)” [String: Combine] & [HUD: ShowHUDMessage];

3.       Click on somewhere in the scene, and the object will move towards to that spot; [Input:Mouse] &  [Movement: MoveEntityTo];

4.       When it arrives the destination, it shows the message: “XXX (Name of Object) has been moved to ….(Coordination)” [String: Combine] & [HUD: ShowHUDMessage];

5.       If click again, the object will move to the new destination; if mouse hovers another object à GO TO STEP 1.

Hints:

1. You may enable modal mode either by a link (as shown in the graph), or by hitting a key on the keyboard. You may set up the key in "Input:Mouse ->Modal mode key". By default it is Number key "0";

2. You may change the parameter "DisableMovement" in "Input:Mouse" to "fause" (0), so that the character would be able to move in the game;

3. In the "Movement: MoveEntityTo" module, change the "Speed" to a reasonable value (I made it 0.5). Objects won't move if it is "0", as set by default;

4. In the "Movement: MoveEntityTo" module, if "DynamicUpdate" is ture (value = 1), then the selected object will move towards wherever the mouse icon is, regardless you click or not; if it is faulse (value = 0), it will only move each time you click; 

5. The Entity Id to the "Movement: MoveEntityTo" module should be the "LastEntityID" from the "Input: Mouse" module. 

Wednesday 20 July 2011

Make someone always look at you and follow you

I have created a simple flowgraph which makes an AI object (e.g: human) always look at and follow the player.


Hints:
1. The Time:Delay function creates a loop that makes sure the AI object always look at and go to the player (check status in every 0.01 second);
2. By changing the variable "B" in the Vec3:AddVec3 function you can decide the distance between the AI object and the player;
3. Please make sure to "Generate all navigation" (under AI tab) to make it work!

To make non-AI object always face player, please refer to this tutorial:
http://www.crymod.com/wiki/index.php/Entity_Always_Facing_Player