Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Alternicity

Newbie
  • Content Count

    7
  • Joined

  • Last visited

  • Days Won

    1

Alternicity last won the day on July 19 2013

Alternicity had the most liked content!

Community Reputation

5 Neutral

2 Followers

About Alternicity

  • Rank
    Newbie

Contact Methods

Profile Information

  • Gender
    Male
  • Location:
    UK
  • Interests
    Gamedev, gardening, home education, beach, sci-fi.
  1. Alternicity

    Rout issue

    Thanks for looking btw, it's really good that there are places like this.
  2. Alternicity

    Rout issue

    Ok here is the code my boy wrote. He's trying to figure it all out for himself, using a framework didn't really occur to him. The goal is 1) education and 2) A nice video of the sim playing out. var speed : float = 5.0; var jumpSpeed : float = 5.0; var postDistance : float = 2.5; var chaseDistance : float = 5; var attackDistance : float = 1.5; var routDistance : float = 5.0; var routLength : float = .1; var HP : int = 10; var target : String; var ally : String; var isFearless : boolean = false; var moraleBonus : boolean = false; var ranged : boolean = false; var lookAtTarget : boolean = true; var dead : boolean = false; var attack : boolean = true; var isRouting : boolean = false; var post : GameObject; //Useful for castles, ranged units, or things like that var routPoint : GameObject; var hurtAnim : AnimationClip; var deathAnim : AnimationClip; var attackAnim1 : AnimationClip; var attackAnim2 : AnimationClip; var attackAnim3 : AnimationClip; var walkAnim : AnimationClip; var rallyAnim : AnimationClip; //Anim for rally which raises loyalty of allied characters. Loyalty is good. var runAnim : AnimationClip; var attackSound1 : AudioClip; var attackSound2 : AudioClip; var attackSound3 : AudioClip; var deathSound1 : AudioClip; var deathSound2 : AudioClip; var deathSound3 : AudioClip; var deathSound4 : AudioClip; var deathSound5 : AudioClip; var hurtSound1 : AudioClip; var hurtSound2 : AudioClip; var hurtSound3 : AudioClip; var hurtSound4 : AudioClip; var hurtSound5 : AudioClip; var hurtSound6 : AudioClip; var hurtSound7 : AudioClip; var hurtSound8 : AudioClip; var hurtSound9 : AudioClip; var hurtSound10 : AudioClip; private var holdOrCharge; private var routOrStay; private var alliesStartedWith; private var deadNoise : boolean; var loyalty : String; //To whom, or which side the characters loyalty lies var loyaltyQuantity : int = 5; //How much they are loyal. (Defines whether they will attack/defend or run?) function Awake() { isFearless = false; deadNoise = false; dead = false; isRouting = false; fire = true; var alliesStart : GameObject[]; alliesStart = GameObject.FindGameObjectsWithTag(ally); alliesStartedWith = alliesStart.Length; var randomNumber = Random.Range(-2, 4); speed = speed+randomNumber; HP = HP+randomNumber+5; HP = HP*10; holdOrCharge = Random.Range(0, 51); if(post == null) { post = gameObject; } } function Update() { var closest : GameObject; var keepHoldingRoutPoint = Random.Range(1,76); var enemies : GameObject[]; enemies = GameObject.FindGameObjectsWithTag(target); var distance = Mathf.Infinity; var position = transform.position; for (var go : GameObject in enemies) { var diff = (go.transform.position - position); var curDistance = diff.sqrMagnitude; if (curDistance < distance) { closest = go; distance = curDistance; } } var allies : GameObject[]; allies = GameObject.FindGameObjectsWithTag(ally); var attackAnim = Random.Range(1,4); var stayOrFight = Random.Range(1, 21); if(HP < 1) { dead = true; } if(!dead) { if(!isRouting) { //if(stayOrFight != 15) //{ if(isFearless) { //attack = true; //lookAtTarget = false; if(Vector3.Distance(transform.position, closest.transform.position) >= chaseDistance) { var rallyMaybe = Random.Range(0, 250); if(rallyMaybe == 150) { animation.CrossFade(rallyAnim.name); //allies.BroadcastMessage("MoraleBoost"); } } } if(attack) { transform.LookAt(closest.transform); if (Vector3.Distance(transform.position, closest.transform.position) <= attackDistance) { if(!animation.IsPlaying(attackAnim1.name) && !animation.IsPlaying(attackAnim2.name) && !animation.IsPlaying(attackAnim3.name)) { if(attackAnim == 1) { animation.CrossFade(attackAnim1.name); closest.BroadcastMessage("Damage"); audio.PlayOneShot(attackSound1); } else if(attackAnim == 2) { animation.CrossFade(attackAnim2.name); closest.BroadcastMessage("Damage"); audio.PlayOneShot(attackSound2); } else { animation.CrossFade(attackAnim3.name); closest.BroadcastMessage("Damage"); audio.PlayOneShot(attackSound3); } } } else { animation.CrossFade(walkAnim.name); transform.Translate(Vector3.forward * speed * Time.deltaTime); } } else { if (Vector3.Distance(transform.position, closest.transform.position) <= attackDistance) { if(attackAnim == 1) { animation.CrossFade(attackAnim1.name); closest.BroadcastMessage("Damage"); } else if(attackAnim == 2) { animation.CrossFade(attackAnim2.name); closest.BroadcastMessage("Damage"); } else if(attackAnim == 3) { animation.CrossFade(attackAnim3.name); closest.BroadcastMessage("Damage"); } transform.LookAt(closest.transform); } else if(Vector3.Distance(transform.position, closest.transform.position) <= chaseDistance && holdOrCharge != 2) { if(!ranged) { animation.CrossFade(walkAnim.name); transform.LookAt(closest.transform); transform.Translate(Vector3.forward * speed * Time.deltaTime); } } else if(lookAtTarget) { transform.LookAt(closest.transform); animation.Play(attackAnim1.name); animation.Stop(); } else { if(Vector3.Distance(transform.position, post.transform.position) <= postDistance) { transform.LookAt(closest.transform); animation.Play(attackAnim1.name); animation.Stop(); } else { transform.LookAt(post.transform); transform.Translate(Vector3.forward * speed * Time.deltaTime); animation.CrossFade(walkAnim.name); } } } var fearless = Random.Range(0,1000); if(fearless == 150) { isFearless = true; } var routNow = Random.Range(0, 150); var alliesRout = allies.Length*alliesStartedWith*.000115; //print(alliesRout); if(alliesRout <= routLength && routNow == 50 && moraleBonus == false) { if(!isFearless) { isRouting = true; } } } else { transform.LookAt(routPoint.transform); transform.Translate(Vector3.forward * speed * 2 * Time.deltaTime); animation.CrossFade(runAnim.name); var holdRoutPoint = Random.Range(1,3); if(Vector3.Distance(transform.position, routPoint.transform.position) <= routDistance) { isRouting = false; if(holdRoutPoint == 1) { attack = true; } else { attack = false; } } } } else { if(!animation.IsPlaying(deathAnim.name)) { animation.wrapMode = WrapMode.ClampForever; animation.Play(deathAnim.name); gameObject.tag = "Dead"; Dead(); } } if(HP <= 0) { dead = true; } } function Damage() { audio.volume = 0.5; var hurtAmount = Random.Range(3,11); HP = HP - hurtAmount; /*if(!animation.IsPlaying(deathAnim.name)) { animation.CrossFade(hurtAnim.name); }*/ var chooseHurt = Random.Range(1,11); if(chooseHurt == 1) { audio.PlayOneShot(hurtSound1); } else if(chooseHurt == 2) { audio.PlayOneShot(hurtSound2); } else if(chooseHurt == 3) { audio.PlayOneShot(hurtSound3); } else if(chooseHurt == 4) { audio.PlayOneShot(hurtSound4); } else if(chooseHurt == 5) { audio.PlayOneShot(hurtSound5); } else if(chooseHurt == 6) { audio.PlayOneShot(hurtSound6); } else if(chooseHurt == 7) { audio.PlayOneShot(hurtSound7); } else if(chooseHurt == 8) { audio.PlayOneShot(hurtSound8); } else if(chooseHurt == 9) { audio.PlayOneShot(hurtSound9); } else if(chooseHurt == 10) { audio.PlayOneShot(hurtSound10); } } function Dead() { audio.volume = 1.0; var chooseDead = Random.Range(1,6); if(!deadNoise) { if(chooseDead == 1) { audio.PlayOneShot(deathSound1); } else if(chooseDead == 2) { audio.PlayOneShot(deathSound2); } else if(chooseDead == 3) { audio.PlayOneShot(deathSound3); } else if(chooseDead == 4) { audio.PlayOneShot(deathSound4); } else if(chooseDead == 5) { audio.PlayOneShot(deathSound5); } } deadNoise = true; yield WaitForSeconds(.9); Destroy(gameObject); } function MoraleBoost() { var becomeBoosted = Random.Range(0, 15); if(becomeBoosted == 5) { moralBonus = true; } }
  3. Alternicity

    Rout issue

    https://dl.dropboxusercontent.com/u/13211994/AI.unitypackage Can we have some help please? We are trying to get the knights to look on guard when they reach their rout point (the boxes in this case). However, we have been unable to succeed at this goal, they just freeze their run animation.
  4. Tom3D - It's great fun. My eldest really seems to be taking to coding Javascript. bentowny - Ok thanks! http://armedunity.com/topic/4498-medieval-ai-project/
  5. Hi, Here is an AI test my son started building whilst we have no access to our old hdd. His brother and I started making assets for it, and this is a quick video and code paste. http://pastebin.com/L90rCvmi We're working on Archers, but progress is slow at the moment because it's beaching weather. The current goal is: learn AI, make a better simulation, have fun. Wide open to any ideas or whatever. Thanks for reading, Stuart, Raph(12), Logan(11)
  6. Thanks for the welcome. Yes all of us are interested in gamedev. We use a Blender > FBX > Unity pipeline.
  7. Hi, I'm a home educating dad from the UK and my kids (ages 11 + 12) and I are interested in gamedev. My eldest boy usually takes the lead with the Unity side of things, and at the moment - when we aren't roasting in this hot weather - we are working on a mediaeval 'AI test'. I am interested in anything that will help us with this and other, stalled projects. cheers for now, Stuart
×
×
  • Create New...