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.

ademir

Newbie
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

4 Neutral

1 Follower

About ademir

  • Rank
    Newbie

Profile Information

  • Gender
    Male
  • Location:
    Brazil

Recent Profile Visitors

206 profile views
  1. ademir

    Photon or Badumna

    thx for all, i continued using photon
  2. ademir

    Photon or Badumna

    As many know, I am creating an online game, I'm currently using photon network. But what would be better, Photon or badumna? //Sorry for my bad english
  3. ademir

    Shoot script!

    (exemple) Replace: HowMuchBulletsTexture * i + 1755 to: Screen.width - HowMuchBulletsTexture * i - 30 and: 870 to: Screen.height - 30 - 10
  4. ademir

    My simple enemy AI

    I fixed the physic on colision in enemy or terrain edited, i fixed using character controller and modify the code //sorry for my bad english
  5. My first post, do not judge me! Simple Ai with move,shot,etc., It's not is full version! var ViewRange = 100.0; var RunAngleDistance = 80.0; var MoveAngleDistance = 40.0; var MoveshotDistance = 20.0; var IdleshotDistance = 5.0; var moveSpeed = 2.0; var TargetTag = "Player"; var PontoAtira : Transform;//shotPoint //HP var maximumHitPoints = 100.0; var hitPoints = 100.0; var deadReplacement : Rigidbody;//Cadaver //Arma Vars var AnimReload= "StandingReloadM4";//Fire Animation var force = 100.0;//Distancia da bala var damage = 3;//Damage var BulletsT = 30; //Total de Balas por Pente var MaxBulletsT = 120; //Total de balas completo var reloadTime = 0.7; //Tempo pra recarregar var accuracy = 1;//Espalha a bala var soundFire : AudioClip;//Som do tiro var soundReload : AudioClip;//Som Carregar var soundEmpty : AudioClip; //Som sem balas private var reload : boolean = false;//esta carregando? private var lBullets : int;//Balas a contar private var lMaxBullets : int;//MaxBalas a contar private var sound : AudioSource;//Gerenciador de som private var Distance; // private var target : Transform; private var nextFireTime = 0.0; private var m_shotPoint : int = 0; /**Enemy HP**/ function OnShotPoint(m_Local : int)//Receiver kill point for head shot, nut shot, etc... { if(hitPoints < 5) { m_shotPoint = m_Local; } } function ApplyDamage (damage : float) { if (hitPoints <= 0.0) return; hitPoints -= damage; if (hitPoints <= 0.0) Replace(); } function Replace() { if (deadReplacement) { var dead : Rigidbody = Instantiate(deadReplacement, transform.position, transform.rotation); dead.rigidbody.velocity = rigidbody.velocity; dead.angularVelocity = rigidbody.angularVelocity; var KillMode : KillScript = dead.transform.GetComponent("KillScript"); KillMode.m_FireMode = m_shotPoint;//head shot, nut shot, etc... } Destroy(gameObject); } // function Start () { //Weapon lBullets = BulletsT; lMaxBullets = MaxBulletsT; sound = gameObject.transform.audio; if(GameObject.FindWithTag(TargetTag)) { target = GameObject.FindWithTag(TargetTag).transform; } } function Update () { if(GameObject.FindWithTag(TargetTag)) { target = GameObject.FindWithTag(TargetTag).transform; if(!CanSeeTarget()) { ParaNoPoint(); return; } var targetPoint = Vector3(target.position.x,0,target.position.z);//target.position; var MainPoint = Vector3(transform.position.x,0,transform.position.z);//target.position; var targetRotation = Quaternion.LookRotation (targetPoint - MainPoint, Vector3.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 4.0); var forward = transform.TransformDirection(Vector3.forward); var targetDir = target.position - transform.position; if(reload) return; Distance = Vector3.Distance(target.position, transform.position); if(Distance < RunAngleDistance) { if(Distance < MoveAngleDistance) { if(Distance < MoveshotDistance) { if(Distance < IdleshotDistance) { FireParado(); } else WalkFireToPoint(); } else WalkToPoint(); } else RunToWalkPoint(); } else { ParaNoPoint(); } } else ParaNoPoint(); } function FireParado() { if(!animation.IsPlaying("StandingFire")) animation.CrossFade("StandingFire"); Atirar(); } function WalkToPoint () { if(!animation.IsPlaying("Walk")) animation.CrossFade("Walk"); transform.Translate(Vector3.forward * moveSpeed* Time.deltaTime); } function RunToWalkPoint () { if(!animation.IsPlaying("Run")) animation.CrossFade("Run"); transform.Translate(Vector3.forward * (moveSpeed*1.5)* Time.deltaTime); } function WalkFireToPoint () { if(!animation.IsPlaying("WalkFire")) animation.CrossFade("WalkFire"); Atirar(); transform.Translate(Vector3.forward * moveSpeed* Time.deltaTime); } function ParaNoPoint () { if(!animation.IsPlaying("Idle")) animation.CrossFade("Idle"); } function CanSeeTarget () : boolean { if (Vector3.Distance(transform.position, target.position) > ViewRange) return false; var hit : RaycastHit; if (Physics.Linecast (transform.position, target.position, hit)) if(hit.transform.tag == transform.tag) return true; else return hit.transform == target; return false; } //Weapon function Atirar() { if(lBullets <= 0 && lMaxBullets > 0)//AutoReload { Reload(); return; } if(lBullets <=0 && lMaxBullets <=0) return; if(reload) return; if(Time.time - 0.3 > nextFireTime)//o 1 e FireRate nextFireTime = Time.time - Time.deltaTime; while( nextFireTime < Time.time ) { VaiAtirar(); nextFireTime += 0.3; } } function VaiAtirar() { var direction = PontoAtira.transform.TransformDirection(Vector3(Random.Range(-0.01, 0.01) * accuracy, Random.Range(-0.01, 0.01) * accuracy,1)); var hit : RaycastHit; if(Physics.Raycast(PontoAtira.transform.position, direction, hit, force))//100 e a distancia { if(hit.rigidbody) hit.rigidbody.AddForceAtPosition(force * direction, hit.point);//100 e a distancia if(hit.collider.gameObject.tag == TargetTag) { var Damage = Random.Range(1,damage); hit.collider.SendMessage("ApplyDammage", Damage, SendMessageOptions.DontRequireReceiver); } } sound.PlayOneShot(soundFire); lBullets-=1; } function Reload () { if(lMaxBullets > 0 &&lBullets != BulletsT) { if(lMaxBullets >= BulletsT) { reload = true; sound.PlayOneShot(soundReload);//Inicia o som de carregando animation.CrossFade(AnimReload);//inicia a animaçao yield WaitForSeconds(reloadTime); lMaxBullets -= BulletsT-lBullets; lBullets += BulletsT-lBullets; reload = false; } else { reload = true; sound.PlayOneShot(soundReload);//Inicia o som de carregando animation.CrossFade(AnimReload);//inicia a animaçao yield WaitForSeconds(reloadTime); lBullets += lMaxBullets; lMaxBullets = 0; reload = false; } } if(lMaxBullets <=0 && lBullets <= 0) { sound.PlayOneShot(soundEmpty); //Empty } } //Sorry for my bad english
×
×
  • Create New...