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.

geckoo

Moderators
  • Content Count

    2,801
  • Joined

  • Last visited

  • Days Won

    151

Everything posted by geckoo

  1. geckoo

    Script help.

    It's cool for an ambiant sound like a music... There is an alternative if your player (or collider) emit a localized sound when he passes nearby the trigger. var sound : AudioClip; function OnTriggerEnter(otherObj: Collider){ if (otherObj.tag == "Player"){ AudioSource.PlayClipAtPoint(sound, transform.position); yield WaitForSeconds(audio.clip.length); }
  2. geckoo

    Code JV for dummies

    I have several questions about the code in package FPS tutorial. They concern the way in which some functions are coded. It seems to me that an alternative is possible, but since the coders behind the project are professionals, I was surprised. I don't understand. For example: (...) // Are we dead? if (hitPoints < 0.0) Die(); } function Die () { if (die) // ??? why this condition ??? AudioSource.PlayClipAtPoint(die, transform.position); var coms : Component[] = GetComponentsInChildren(MonoBehaviour); for (var b in coms) { var p : MonoBehaviour = b as MonoBehaviour; if (p) p.enabled = false; } yield WaitForSeconds(3); Application.LoadLevel (1); } Why was it necessary to introduce a second condition in the Die function? If you get on this feature, the player is already dead? : hitPoints < 0 !!! It's a fact... I tried without this condition - I have not seen any change. A second example : if (!CanSeeTarget ()) return; var targetPoint = target.position; var targetRotation = Quaternion.LookRotation (targetPoint - transform.position, Vector3.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.0); alertOn(); (...) Why declare the variable Targetpoint? Is it not easier to avoid the variable inside the function? var targetRotation = Quaternion.LookRotation (target.position - transform.position, Vector3.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.0); These are not errors, but I was wondering - why? I know that the clarity of the code is very important and that we get lost in the maze quickly. Therefore, why must code these functions by this way? Maybe it is not a problem - just a way of working. Thank you for sharing your opinion with the dummie that I am ++
  3. If you had a bit searched on the forum, you would have seen that I wrote a text about this script yesterday. http://armedunity.com/topic/5002-loop-in-update-function/?hl=loop
  4. Спасибо за предложения. Я сталкивался с трудностями, пробуя определить некоторые слова из твоего текста, но мне кажется, что я понял самое главно - практиковать каждый день "чуть-чуть" и в конце концов можно достичь своей цели - владеть кодом JV. На самом деле, читать/понять его очень легко. Можно ещё изменить некоторые аспекты кода и попробовать разные варианты. Но к сожалению, создать какой-то полный код - то есть размышлять точно и обрести логику, чтоб созидать сложный код - это другое дело. Они говорят по-русски свободно в Латвии. Я не знал. Огромное спасибо тебе за советы ++ I found a really good example. It's very explicite : function PlayStepSounds () { var controller : CharacterController = GetComponent(CharacterController); while (true) { if (controller.isGrounded && controller.velocity.magnitude > 0.3) { audio.clip = walkSounds[Random.Range(0, walkSounds.length)]; audio.Play(); yield WaitForSeconds(audioStepLength); } else { yield; } } }
  5. Трудно мне уже отличать этот метод от других. Даже если я понял теорию, есть ещё практическое упражнение. Продолжаю искать и вы знаете выражение - кто ищёт, тот найдёт... Прежде всего, я решил исследовать аккуратно код из fps_tutorial. Этот исходник очень интересен ++
  6. На самом деле, я только попробовал понять этот принцип. Я не создал ничего особенного. Я исследовал код и я заметил много аспектов, которые можно изменить/совершенствовать. Чтоб сделать эти изменения, я должен обязательно понять как всё идёт - как один код соединяется с другими... вот почему я задал вам такой вопрос. Спасибо за помощь ++ I try to understand how this code was developed and how i can modify many details (it's a begining). It so confused for me and i have so many questions... I was coder - ASM and C/C++ - rootkit, BOF, backdoor, shellcode - an another world, but I forgot many lessons. I work on it. Thanks boys because you helped me.
  7. That will work only if both script are attached to the same gameobject. ...and this is why I did not understand your explanation. Thanks you very much for help ++
  8. Ok I understood : var lol : scriptX = GetComponent(scriptX); lol.functionX(); lol.variableX ++; etc... Thx for support. It's a new language for me ++
  9. NullReferenceException: Object reference not set to an instance of an object Hum... i don't understand something I read the tutorial ++
  10. SendMessage "function-name" has no receiver! I forgot something... I don't understand boys. Can you explain to me? I try second method with GetComponent. Thx ++
  11. Thx for support I don't have to call something in script to attach this second script at first? I try it ++
  12. Again a silly question. In a script JS, how i can call a function who is in an another script? I read this information in a tutorial but i forgot. Thanks you for support ++
  13. Full code if you wanna read it and comment it (SentryGun.js by OMA in fps_tutorial - original code by Joachim Ante). Replace the original code, find a sound and try it ++ @script RequireComponent(AudioSource) var attackRange = 33.0; var shootAngleDistance = 15.0; var target : Transform; var detected : AudioClip; var audioAlarmLength = 2; var countdown = 1; // 2 or 3 for an echo effect with the alert sound // who is my target? - i am function Start () { if (target == null && GameObject.FindWithTag("Player")) target = GameObject.FindWithTag("Player").transform; } function Update () { if (target == null) return; if (!CanSeeTarget ()) return; // Oups! Turret see us // Rotate towards target var targetPoint = target.position; var targetRotation = Quaternion.LookRotation (targetPoint - transform.position, Vector3.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.0); alertOn(); // alternative 1 (my choice) // If we are almost rotated towards target - fire one clip of ammo var forward = transform.TransformDirection(Vector3.forward); var targetDir = target.position - transform.position; // Angle OK - shoot him! if (Vector3.Angle(forward, targetDir) < shootAngleDistance) { SendMessage("Fire"); // alertOn(); // alternative 2 } } // alt 1 - this function emits a sound when the turret see the player (or) // alt 2 - this function emits a sound when the turret send a "fire" message (or) // alt 3 - this function emits a sound when the turret can see the player (make the difference with first alternative) function alertOn () { if (countdown == 0) return; else AudioSource.PlayClipAtPoint(detected, transform.position); countdown --; // to avoid too many sound in process (update function causes this annoying effect) yield WaitForSeconds(audioAlarmLength); countdown ++; // again } function CanSeeTarget () : boolean { // Player is too far of her enemy (no danger) if (Vector3.Distance(transform.position, target.position) > attackRange) return false; // In an other case, turret shot him because player is too near of our turret var hit : RaycastHit; // alertOn(); // alternative 3 // if you prefer, you can call function alertOn when the turret can see the player. if (Physics.Linecast (transform.position, target.position, hit)) return hit.transform == target; return false; }
  14. Finally i found this way, but i don't know if it's really professional In the meantime, it works pretty well ++ var countdown = 1; // or 2/3 for an echo effect function alertOn () { if (countdown == 0) return; else AudioSource.PlayClipAtPoint(detected, transform.position); countdown --; yield WaitForSeconds(audioAlarmLength); countdown ++; }
  15. Hello. I have a problem of understanding, which I would submit to you. I want to add a sound on this script to trigger an alert. I created a function for sound and it works ... but as an annoying loop because I'm in the Update function. Inevitably I end up with a lot of appeal to this function. So chaos. I am looking for a way to create a condition on this function so that it is played once. What do you think? THX friends ++ Tutorial_fps (by OMA) function Update () { if (target == null) return; if (!CanSeeTarget ()) return; // Oups! Turret see us // Rotate towards target var targetPoint = target.position; var targetRotation = Quaternion.LookRotation (targetPoint - transform.position, Vector3.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.0); // If we are almost rotated towards target - fire one clip of ammo var forward = transform.TransformDirection(Vector3.forward); var targetDir = target.position - transform.position; // Angle OK - shoot him! if (Vector3.Angle(forward, targetDir) < shootAngleDistance) { SendMessage("Fire"); alertOn(); } } function alertOn () { AudioSource.PlayClipAtPoint(detected, transform.position); return; }
  16. geckoo

    Orb - FinalPK0.85

    Ok I understand. Thanks for this idea ++
  17. geckoo

    Orb - FinalPK0.85

    Orb would look much better if I replace it with this drone? Ok. I try... But it will be more efficient? It's an other script? It's the same IA?
  18. geckoo

    Orb - FinalPK0.85

    It's alright. I found my mistake and I fixed it. It's a silly taping error when i wrote the name of the empty object - TargetPoint (мне позор). Sorry for the inconvenience. I lost many precious time for this stupidity. Как говорят, у всех так бывает... This script is really cool with a funny movement and effect when Orb chasing. It's most than a simply turret and It conserves again an IA interesting - rudimentary, but efficient. Thx ++
  19. geckoo

    Orb - FinalPK0.85

    Hi all. I try to use in an empty project the amazing Orb (FinalPK0.85). I don't understand how i can attribute the target. In original project, it's really clear, but i can't reproduce this process with a simply "First Person Controller". Must I specify the camera's position or an other parameter? Thanks ++
  20. It's a (bad) habit to end my tickets like this. It's possible to translate it by "see you later alligator" Oups i forgot ++
  21. Very impressive. It's a good work ++
  22. geckoo

    7dFPS 2013

    You can find on this page the result of last 7dFPS. A lot of this games are developed on Unity, and some are strange. There are good ideas ++ Вы можете в этой странице обнаружить много игр, которые были созданы посредством Unity. Результат интересен. Попробуйте братья ++ http://7dfps.com/?action=games&sort=most_likes
  23. Exactly. We often make this mistake when we start in programming, forgetting gap/ratio with the resolution of screen. The difference is important. Thank you for free distribution. This code is really usefull ++
  24. Hi all! I don't understand how i can redefine a new grid to use the A* Path Finding. In the map Arena (FPS Kit premium 0.85) i create a simple bridge (not an obstacle), but spiders don't change the way. I thought that A* recalculate all the zone to find the better way. Maybe you can explain to me. Thanks you ++ Чёрт! Я сталкиваюсь с трудностями, чтоб понять принципу, но продалжаю искать решение. Помогите пожалуйста. Спасибо ++
×
×
  • Create New...