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.

silasfriedrich

Member
  • Content Count

    37
  • Joined

  • Last visited

Community Reputation

1 Neutral

About silasfriedrich

  • Rank
    Member
  • Birthday 02/27/1996

Profile Information

  • Gender
    Male
  • Location:
    Germany
  1. silasfriedrich

    Spawning system

    Hi everyone, I have trouble with my spawning system and I can't find a good way to get it to work. So basically in my game you should build a tower with blocks (cubes). And every time you place a new block a new block should spawn at a random spawn. So I worked hours on this and im really bad at scripting. This is what I have : This script is on the blocks: using UnityEngine; using System.Collections; using System.Collections.Generic; public class spawner : MonoBehaviour { public GameObject daspawn2; public bool working = false; public bool ok = false; public bool verloren2 = false; //public BoxCollider boxCol; void Update () { if (!GameObject.Find ("hand2").GetComponent<HandPhysicsController> ().IsHoldingObject2) { ok = true; } else { ok = false; } } void OnTriggerEnter(Collider other){ if(other.tag == "trigger") //if(ok == true) if(verloren2 == false) working = true; daspawn2.SetActive(true); } void OnTriggerExit(Collider other){ if (other.tag == "trigger") if(ok == true) verloren2 = true; } } This is on the base you build on: using UnityEngine; using System.Collections; using System.Collections.Generic; public class gamelogic : MonoBehaviour { private bool ok = false; public bool verloren = false; public Transform[] spawns; public int amountThings = 1; public int i = 0; public Transform[] Bone; void Update () { if (!GameObject.Find ("hand2").GetComponent<HandPhysicsController> ().IsHoldingObject2) { ok = true; } else { ok = false; } } void OnTriggerEnter(Collider other){ if(other.tag == "Block") if(ok == true) if(verloren == false) //activate when readyyyy Spawn(); } public void Spawn() { List<Transform> freeSpawnPoints = new List<Transform>(spawns); List<Transform> freeobjects = new List<Transform>(Bone); for (i = 0; i < amountThings; i++) { if (freeSpawnPoints.Count <=0) return; // Not enough spawn points int index = Random.Range(0, freeSpawnPoints.Count); int randomi = Random.Range(0,freeobjects.Count); Transform pos = freeSpawnPoints[index]; freeSpawnPoints.RemoveAt(index); // remove the spawnpoint from our temporary list freeobjects.RemoveAt(randomi); // remove the object from our temporary list Instantiate(Bone[randomi], pos.position, pos.rotation); } } void OnTriggerExit(Collider other){ if (other.tag == "Block") if(ok == true) verloren = true; } } and this is on a empty gameobject: using UnityEngine; using System.Collections; using System.Collections.Generic; public class spawn : MonoBehaviour { public GameObject daspawn; public bool gut = false; public Transform[] spawns; public int amountThings = 1; public int i = 0; public Transform[] Bone; void Update () { if (GameObject.Find ("Block").GetComponent<spawner> ().working) { gut = true; Spawn2(); } } public void Spawn2() { List<Transform> freeSpawnPoints = new List<Transform>(spawns); List<Transform> freeobjects = new List<Transform>(Bone); for (i = 0; i < amountThings; i++) { if (freeSpawnPoints.Count <=0) return; // Not enough spawn points int index = Random.Range(0, freeSpawnPoints.Count); int randomi = Random.Range(0,freeobjects.Count); Transform pos = freeSpawnPoints[index]; freeSpawnPoints.RemoveAt(index); // remove the spawnpoint from our temporary list freeobjects.RemoveAt(randomi); // remove the object from our temporary list Instantiate(Bone[randomi], pos.position, pos.rotation); daspawn.SetActive(false); } } } Now what working is you place a block on the base. Then a new block spawns at a random location. But if I place the new block on the other it only spawns a new one and then it does not spawn more. Its because I decativated the gameobject holding the spawner script. But I cant find a good way to actiate it again. Does someone have a good idea? Thanks for ever answer Here is a Screenshot of the block and components:
  2. silasfriedrich

    make a static box collider

    Hi everyone, I have a door that opens and its rotated then, so the problem is there that the boxcollider which defines the area where you can open the door, moves to. So how can I make that this boxcollider does not move when the door moves? Thanks
  3. silasfriedrich

    delay in update function

    Works perfect thx
  4. silasfriedrich

    delay in update function

    Hi everyone, I have a script for open and close a door and I want to make that the sound close have a delay of 1 second. Does anyone know how i can do this ? this is my function for closing the door: if (Input.GetButtonUp("Fire1") && IsOpen && CanOpen) { StartCoroutine (Closing ()); IsOpen = false; audio.PlayOneShot(close); }
  5. silasfriedrich

    Pickup script

    Hi everyone, does someone know or have a script where if you look at a object it gets highlighted (change color, get a border or something). thanks
  6. silasfriedrich

    Waitforseconds doesnt work

    Hi everyone, I have a script that play randomly audio and now i want a delay after every sound. I tried using waitforseconds function but i cant get it to work. this is the script: var sounds: AudioClip[]; InvokeRepeating("PlayRandom", 0, 1); function PlayRandom(){ if (audio.isPlaying) return; audio.clip = sounds[Random.Range(0,sounds.length)]; audio.Play(); } Thanks
  7. silasfriedrich

    Door does not work

    Do you know how I can make that the door can only be open when on a other script public bool locked = flase; is ?
  8. silasfriedrich

    Door does not work

    Thanks this one works perfectly.
  9. silasfriedrich

    Door does not work

    Hi everyone, I have a problem with making a door. I know how to create a animation for it (I made an empty gameobject and used it as a rotation point). But It never works correctly, I tried so many diffrent scripts an tutorials but it never works. So, does someone know a easy script for open and closing a door? Thanks
  10. silasfriedrich

    Audio does not play

    Hi everyone, i have a problem with a script that should play sounds in a random order. But I cant hear anything when I test it. This is the script: var sounds: AudioClip[]; function PlayRandom(){ if (audio.isPlaying) return; audio.clip = sounds[Random.Range(0,sounds.length)]; audio.Play(); } I attached the script to a empty gameobject and addet the sounds and a audio source to the object. Does anyone know how to fix this? (my player has a audio listener) thanks
  11. silasfriedrich

    Candela SSRR white line error

    Hi everyone, so I bought candela SSRR yesterday and its awesome. But in front of my camera is a white line. Does anyone have an idea why this line is there ?
  12. silasfriedrich

    Make a infinite terrain for a MMO.

    yeah, but how can I make that it loads the terrain piece by piece. Because if I have a big terrain like in WOW it would take forever to load.
  13. silasfriedrich

    Make a infinite terrain for a MMO.

    yeah, but I want a terrain that get procedurally loadet or is it diffrent in WOW ?
  14. silasfriedrich

    Make a infinite terrain for a MMO.

    I dont want a generated terrain I want to load my terrain like in WOW. So I have a big map and the map gets loadet while playing
  15. silasfriedrich

    Make a infinite terrain for a MMO.

    you right. So does anybody know how to do this ?
×