Monday, August 24, 2015

Tinker: Enemy NPC-Mutants: Version 1

Troika
Mechanical organic synths designed for search and rescue, first response and stalking zones of danger. Equipped with a directed energy weapon. Size varies from child size to human and above. The Troikas operate independently and in groups. The bigger Troika is the mother brain.
Zipper
The Zipper is a mutant created from Venus Flytrap dna and simian. The creature was later warped by the zone. It prefers dark places in the Tartaric forest and occasionally abandoned buildings. Its agile and quick, preferring to use sharp claws to dispatch victims. It added feature is that it can split its body in half to consume its food.
Balrog
Is a mutation in the zone by the zone it self. They are asexual and are often alone or in groups of three. Their sizes vary as does their skin color. The lowest is tan, red and highest is green. Their hostility varies. They are found roaming in the Tartaric forest, near the mountains and in abandoned buildings.
Rot
Formarly people exposed to high doses. They work on smell, as their eyes have burned out. Physically strong and capable of taking high damage they are very dangerous and very hostile; as their brains have been leasioned by the Psi pulses in the zone.
Vampyre
A disgusting, unintelligent, furious, shrieking horror prone to violence from the depths of the bio research lab, the Vampyre is an abomination walking the lands. Hostile, fast and agile this being prefers to use its fangs to slash at it victims. Found walking around day and night in the upper east part of the zone, these beings stalk the old research complexes.
Blind Dog
Mutants, found in darker areas, forests, caves, and buildings. They are timid and territorial at first. Blind by birth they are easily evaded, however antagonizing them will lock the persons smell. Every interaction from them on will always make them violent. They are very fast and capable of strong bites and tears with their font paws.
Razor
Reclusive and found in the Tartaric forest, Razors travel in small packs and show signs of communication by high shrieks or low growls as well as complex social structure to the point of developing housing, totems and written glyphs. Despite their intelligence, they have no need for weapons(though its suspected they can use them) their long arms give them a great reach and quick movement of their arms make for good defense coupled with their sharp and tempered frontal head makes them a danger. They wont attack unless provoked, usually by attacking their totems or standing to long in their "villages".

Sunday, August 23, 2015

Basic AI: Part 2

The AI we developed in the last post has a few limitations. If had the chance to play around with it you saw that the bots have a tendency to float when you jump. Now this isn't necessarily bad depending on the type of bot you want to make. For example you could make a small quadcopter drone or some type o hovering drone. But if we want real humanoids and animals we need to fix that problem.
The second limitation is that the moment you start the bots begin chasing you. In a real game this isnt bad depending on the context. For example say your character reaches a reputation of negative 45. Now we want to spawn a bounty hunter to dispatch the character. We dont want the spawn point to be close but not really far. We want to add the illusion on long distance travel. So we would create the point close to the player and spawn the bot and have it immediately seek out the player.

For this tutorial we will address these two points. You will need the past code for this tutorial, the link for it is here: Chase AI

In Unity the up/down variable is 'y'.  This will be used for our gravity. What we will do is check if the bot is grounded, if its not, we will take the my_Velocity Vector variable and adjust the 'y' value of it and set it to zero.

if(!chase_AI.isGrounded)
{
      my_Velocity.y = 0;
}

Now we will set some conditionals for when the bots will chase you. We will have two triggers, one will be timed. After a few seconds or minutes the bots will start. The other will be an invisible collider, when the player walks through it will begin chasing the player.


Triggered Chase:

First off  add a Sphere object to the game world and remove the Mesh Renderer component, then rename it to SphereTrigger, link the Sphere object to the bot (Note i call the bots Cylinders after the object). Next we need to make a new script that will be placed in the SphereTrigger. Name it 'ChaseTrigger', this script when finished and compiled will be attached to you Sphere object. Now place the Sphere object in front of your player character or somewhere in the scene.

 







Next make a new script and name it 'ChaseTrigger'. This script is straight forward, it will use an intrinsic function, a conditional and a boolean. This script will be accessed by the main AI script we will make. 


What we are doing here is using OnTriggerEnter(). This function is used on objects that serve as triggers for other events or actions. Within that function we use an if statement that checks if the object that collided with the OnTriggerEnter() is tagged as "Player"
(collision.gameObject.tag == "Player"). 
If so the the boolean value is set to true: collisionTrigger = true;

Next, copy the Basic AI script and make a new script, paste the script there. Make sure that the name of the script matches the name in the script. Next we need to make two variables one a game Object the other a script object.


The two new variables are the GameObject SphereColliderTrigger; this game object will do two things, one, it will be the placeholder for the sphere collider you place in the game earlier. Two, access the variables from the next variable which is an instantiate of the ChaseTrigger script you made: ChaseTrigger sphereTrigger.
Next we have to initialize the sphereTrigger script with the values by holding the values in the SphereColliderTriggerObject, this has to be done only once so place it in the Start() function.


Now for the Update(), it will just have a conditional.


if(sphereTrigger.collisionTrigger), is the main conditional. The initialized script from prior is calling the variable in its self: collisionTrigger to see if it has been set to true. The rest of the code is the same. 
Finally make sure to set all the fields of the scripts.

Press play and go.


Timed Chase:

This version is by far the fastest. All we need are two variables, a time to detonate: public float timeToBeginChase and a timer to be incremented till it reaches the threshold to detonate: public float timer. Copy the original Basic Basic AI script and add the following two variables in the heading.


Now in the Update() we need to update the timer variable and compare it to its detonation threshold.


The line: timer +=  1 * Timer.deltaTime; increments the variable timer each frame. The variable is later compared in the line if(timer >= timeToBeginChase) if the timer value is greater than or equal to 5, then the bot will be triggered. Now compile, and attach the script to a bot. As always remember to set the fields of the script like above. The code for all three scripts is below.

Chase Triggered, and timed

Other methods of AI include gauging the distance between a bot and player, making judgment calls, "sight" and "sound". Maybe ill try and make a few for examples.

Tuesday, August 18, 2015

Back - Recent Assets

Im back, with new assets. Ill be posting an expanded tutorial on the previous post Basic Basic AI. Then after that i should publish one more, a basic firearm tutorial.