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.

Search the Community

Showing results for tags 'gameobject'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • GENERAL
    • Introduce yourself
    • Discussions
    • Showcase
    • Need help?
    • Seeking team members?
    • Offtopic
  • RESOURCES
    • Example Projects
    • Scripts
    • Shaders
    • Unity Tutorials
    • FPS Kit Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
  • SELL | REQUEST
    • Sell
    • Request
  • Mars' Modular Multiplayer Photon FPS Kit's Topics
  • Mars' Modular Multiplayer Photon FPS Kit's Reviews
  • Mars' Modular Multiplayer Photon FPS Kit's Updates
  • Mars' Modular Multiplayer Photon FPS Kit's Tutorials
  • Busy People's Introductions
  • Photon's Tutorials
  • Photon's Photon General
  • Photon's Showcase

Categories

  • Free Projects
  • Free Assets
  • Game Demos
  • Photon's Files

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


YouTube URL


Facebook URL


Twitter URL


IndieGoGo URL


Kickstarter URL


IndieDB URL


GreenLight URL


Location:


Interests

Found 10 results

  1. I have a gun script in which I have declared Now I wanna assign the weaponCamera of gun script from its parent's parent's to its parent(MainCamera). Means like this FPSController>Lean(empty gameobject)>MainCamera(i wanna assign this)>Body_1(gameobject)>Arms(gameobject)>M4A1. FPS controller>Soldier. I dont wanna assign camera manually to inspector because I instantiate clone of m4 gameobejct. Similarly I have declared I wanna assign this gameobject from FPSController's child to GameObject of GunScript.(public GameObject Soldier;) I know the question is pretty hard(or may i dont know how to ask questions like this). I tried various codes like : But it didnt work! Im stuck w/ it since Monday. Don't make comments on my english. NVM!
  2. I'm sorry for my English. My Unity 2017.3.0f2 worked fine yesterday, but when I loaded my project today, it froze when I tried to create an instance of the object, identify the code that caused this error and I share it with you, I do not know what the problem was inside the code, it worked fine yesterday , I thought that the cycle produces this error, but I do not see anything wrong inside the code, please need help with my code, what I try is to capture all the Gameobjects in front of the object, and that they are saved in an array, to later use the position of these GameObject to instantiate a bomberman-style bomb, and check for hits.Length greater than zero. Here I leave the code already commented: void CaptureAllDelante(){ RaycastHit[] hits; hits = Physics.RaycastAll(transform.position, Vector3.forward, Potencia); int i = 0; print ("Check if hits.length greater zero // " + hits.Length.ToString()); while (i < hits.Length) { if (hits [i].transform.tag == "Paredes" || hits [i].transform.tag == "Player" ) { break; //"if object tag is Paredes / Player, Stop while" } else if(hits [i].transform.tag == "Destructibles"){ //"if object tag is Destructibles , save object in array ObjetosDelante for use the position later" RaycastHit hit = hits[i]; ObjetosDelante [i] = hits [i].transform.gameObject; Debug.Log (hit.collider.gameObject.tag.ToString()); i++; } } for (int a = 0; a < ObjetosDelante.Length; a++) { if (ObjetosDelante[a] == null) { break; } //"if ObjetosDelante if != null instantiate Explosion in each position of object in array" Instantiate (Explosion, ObjetosDelante[a].transform.position,Quaternion.identity); } SearchObjetoDelante = false; }
  3. so i want a gameobject to be at the top of another cube, but i am not able to.. the script doesnt work for me .. where am i going wrong? var obj : GameObject; function Update () { var mes : Mesh = obj.GetComponent(MeshFilter).mesh; transform.position = mes.bounds.max; }
  4. 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:
  5. Hello everyone! i just need a tiny bit of help. So i have a respawn script that works fine (Realistic FPS prefab item spawner) but the only problem is that for example i set the Item to respawn for 10 seconds but when i press play it spawns right away and when i pickup the object then it spawns 10 seconds later how do i fix the item from spawning when scene is played??? //Test script for repeated item spawning. using UnityEngine; using System.Collections; public class WeaponSpawn : MonoBehaviour { public GameObject gunPrefab; public float spawnTime = 30.0f; public GameObject gunInstance = null; private float timeLeft; void Start (){ timeLeft = 0; // You don't need to have weapons from the beginning } void Update (){ if(timeLeft > spawnTime || gunInstance){ timeLeft = spawnTime; }else if(timeLeft <= 0){ timeLeft = 0; Spawn(); } if(!gunInstance){ timeLeft-=Time.deltaTime; // Reduce the time counter } } void Spawn (){ // Make an instance of the weapon gunInstance = Instantiate(gunPrefab,transform.position,transform.rotation) as GameObject; timeLeft = spawnTime; // Reset the time needed to the normal amount of time } }
  6. i just finished making a character creation system . But how can i save the created character? player prefs? as a new prefab? because i will have to instantiate it in the next scene.
  7. Hi everyone, Im sorry if i ask to many questions but im a noob at unity . So I have this script: function Awake () { DontDestroyOnLoad (transform.gameObject); } And its working perfect but now : this script is on a object in the scene 1 now i load scene 2 and its still there but now if I die in the scene 2 and press replay so it loads the scene again the object is gone. How can I fix that? Im thinking about a loop or something will work so i tried this: function Awake () { DontDestroyOnLoad (transform.gameObject); } function Update () { while() { Awake(); yield; } } but i dont know what to write in the condition of the while.
  8. Hi, I have a gameobject called Trees that have some trees inside, it begins inactive or I also can disable through this code in C#: if(Input.GetKeyUp(KeyCode.Space)){ GameObject.Find("Trees").active = false; } But when i want to reactivate it with: GameObject.Find("Trees").active = true; unity cant find the gameobject, is there a way to find it and activate it again? Im new if you could explain i would apreciate a lot. Thanks.
  9. Hi, Im making a multiplayer FPS and have just recently added a Sniper rifle with a scope on it. This all works great, but if I spawn myself far away from any buildings/gameObjects and look at them through the sniper scope they bug out and don't render properly. I have attached an image to show what I mean. Any ideas why? NOTE: This image was cropped to fit the filesize limit for Unity Answers, but their website doesn't work for me. :/
  10. Hey Guys I started to make a funny Script that is creating Cube Prefabs Randomly. Only add this Script to an Empty Gameobject or something else and set up the Prefabs which should Spawn. It is very funny if you add those Prefabs Rigidbodys! . Here is the Video: http://www.youtube.com/watch?v=StW0PKbdljk Hope you like it heres the Script: //Add this Variables to whatever you want? var GrassBlock:GameObject; var DirtBlock:GameObject; var GlassBlock:GameObject; var WoodPlankBlock:GameObject; function Start () { } function Update () { var BlockNumber:int = UnityEngine.Random.Range(0,5); if(BlockNumber == 1){ //yield WaitForSeconds(1); var Block1:GameObject = Instantiate(GrassBlock, transform.position, transform.rotation); } if(BlockNumber == 2){ //yield WaitForSeconds(1); var Block2:GameObject =Instantiate(DirtBlock, transform.position, transform.rotation); } if(BlockNumber == 3){ //yield WaitForSeconds(1); var Block3:GameObject =Instantiate(GlassBlock, transform.position, transform.rotation); } if(BlockNumber == 4){ //yield WaitForSeconds(1); var Block4:GameObject =Instantiate(WoodPlankBlock, transform.position, transform.rotation); } }
×
×
  • Create New...