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.

lucian112

Member
  • Content count

    47
  • Joined

  • Last visited

Community Reputation

2 Neutral

1 Follower

About lucian112

  • Rank
    Member
  • Birthday

Profile Information

  • Gender
    Male
  • Location:
    Romania
  • Interests
    Comunity helping in unity 3d!

Contact Methods

Recent Profile Visitors

412 profile views
  1. Hello guys! I have a question. Can i make a player to teleport on specify cords like x,y,z?I have a script when player fall,to teleport on cords,but i want now to teleport back when is colision like with a bullet. Here is my script using UnityEngine; using System.Collections; public class respawn : MonoBehaviour { public float threshold; void FixedUpdate() { if (transform.position.y < threshold) transform.position = new Vector3(9, 180, 10); } } Thanks! Srry for bad languege or explain
  2. Hello guys. I have a question. Is existed a script(or tutorial) on internet when player die on multiplayer like when colision with bullet to respawn on checkpoint?
  3. Hello guys. I need help. Can anyoane to help me with script or other to make on my multiplayer game to hide a camera. like in fps cam for player who control his charachter to show his gun in fps just for others -players to not showing his view in his hand,like fps arms. Thanks
  4. Here is my first script,it is about shooting. Easy to use,just create empty game object on charachter camera. I forge to put script: using UnityEngine; using System.Collections; public class Shooting : MonoBehaviour { public Rigidbody projectile; public float speed = 30f; void Start() { Cursor.visible = false; } // Update is called once per frame void Update() { if (Input.GetButtonUp("Fire1")) { Rigidbody instantiatedProjectile = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody; instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(0, 0, speed)); } } } And one more thing. On bullet need to add raycast,and mass need to be 0.05(bullet prefab can be a sphere,cilindre,cube,etc.... just is obligatory to have raycast for work!)
  5. I can't find semicolon. You can be exactly please?
  6. I have this error: Assets/CircularMenu.cs(59,5): error CS1002: ; expected Script: using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Collections.Generic; using UnityEngine.UI; public class CircularMenu : MonoBehaviour { public List<MenuButton> buttons = new List<MenuButton>(); private Vector2 Mouseposition; private Vector2 fromVector2M = new Vector2(0.5f,1.0f); private Vector2 centercirlce = new Vector2(0.5f, 0.5f); private Vector2 toVector2M; public int menuItems; public int CurMenuItem; private int OldMenuItem; // Use this for initialization void Start () { menuItems = buttons.Count; } // Update is called once per frame void Update () { GetCurrentMenuItem(); if (Input.GetButtonDown("Fire1")) ButtonAction(); } public void GetCurrentMenuItem() { Mouseposition = new Vector2 (Input.mousePosition.x, Input.mousePosition.y); toVector2M = new Vector2(Mouseposition.x/Screen.width, Mouseposition.y/Screen.height); float angle = (Mathf.Atan2(fromVector2M.y = centercirlce.y, fromVector2M.x - centercirlce.x) - Mathf.Atan2(toVector2M.y = centercirlce.y, toVector2M.x - centercirlce.x)) = Mathf.Rad2Deg; if (angle < 0) angle += 360; CurMenuItem = (angle / (360 / menuItems)); if(CurMenuItem != OldMenuItem) { buttons[OldMenuItem].sceneimage.color = buttons[OldMenuItem].NormalColor; OldMenuItem = CurMenuItem; buttons[CurMenuItem].sceneimage.color = buttons[OldMenuItem].HighlightedColor; } } public void ButtonAction() { buttons[CurMenuItem].sceneimage.color = buttons[CurMenuItem].PressedColor; if(CurMenuItem == 0) print("You have pressed the buttonn") } } [System.Serializable] public class MenuButton { public string name; public Image sceneimage; public Color NormalColor = Color.white; public Color HighlightedColor = Color.grey; public Color PressedColor = Color.gray; } Thanks
  7. Thanks,and i'm so sorry for spaming and my small info on programing
  8. Hello,here is my script,srry a lot for spaming,just i try to make a game by a tutorial of youtube. Here is error: error CS1525: Unexpected symbol `if' Script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class BuildingSystem : MonoBehaviour { public List<buildObject> objects = new List<buildObject>(); public buildObject currentobject; private Vector3 currentpos; private Vector3 currentrot; public Transform currentpreview; public Transform cam; public RaycastHit hit; public LayerMask layer; public float offset = 1.0f; public float gridSize = 1.0f; public bool IsBuilding; public MCFace dir; void Start() { ChangeCurrentBuilding(0); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } void Update() { if (IsBuilding) startPreview(); if (Input.GetButtonDown("Fire1")) Build(); if (Input.GetButtonDown("0") || Input.GetButtonDown("1")) switchCurrentBuilding (); } public void switchCurrentBuilding() { for(int i = 0; i < 2; i++) { if (Input.GetKeyDown("" + 1)) ChangeCurrentBuilding(i); } } public void ChangeCurrentBuilding(int cur) { currentobject = objects[cur]; if (currentpreview != null) Destroy(currentpreview.gameObject); GameObject curprev = Instantiate(currentobject.preview, currentpos, Quaternion.Euler (currentrot) ) as GameObject; currentpreview = curprev.transform; } public void startPreview() { if (Physics.Raycast(cam.position, cam.forward, out hit, 10, layer)) { if (hit.transform != this.transform) showPreview(hit); } } public void showPreview(RaycastHit hit2) { if(currentobject.sort == objectsorts.floor) { dir = GetHisFace(hit2); if(dir == MCFace.Up || dir == MCFace.Down) { currentpos = hit2.point; } else { if (dir == MCFace.North) currentpos = hit2.point + new Vector3(0, 0, 2); if (dir == MCFace.South) currentpos = hit2.point + new Vector3(0, 0, -2); if (dir == MCFace.East) currentpos = hit2.point + new Vector3(2, 0, 0); if (dir == MCFace.Weast) currentpos = hit2.point + new Vector3(-2, 0, 0); } } else currentpos = hit2.point; currentpos -= Vector3.one * offset; currentpos /= gridSize; currentpos = new Vector3(Mathf.Round(currentpos.x), Mathf.Round(currentpos.y), Mathf.Round(currentpos.z)); currentpos *= gridSize; currentpos += Vector3.one * offset; currentpreview.position = currentpos; currentpreview.position = currentpos; if (Input.GetButtonDown("Fire2")) currentrot += new Vector3(0,90,0); currentpreview.localEulerAngles = currentrot; } public void Build() { PreviewObjects PO = currentpreview.GetComponent<PreviewObjects>(); if (PO.IsBuildable) { Instantiate(currentobject.prefab, currentpos, Quaternion.Euler (currentrot) ); } } public static MCFace GetHisFace(RaycastHit hit) { Vector3 incomingVec = hit.normal - Vector3.up; if(incomingVec == new Vector3(0,-1,-1) ) return MCFace.South if(incomingVec == new Vector3(0, -1, 1)) return MCFace.North; if(incomingVec == new Vector3(0, 0, 0)) return MCFace.Up; if(incomingVec == new Vector3(1, 1, 1)) return MCFace.Down; if(incomingVec == new Vector3(-1, -1, 0)) return MCFace.Weast; if(incomingVec == new Vector3(1, -1, 0)) return MCFace.East; return MCFace.None; } } [System.Serializable] public class buildObject { public string name; public GameObject prefab; public GameObject preview; public objectsorts sort; public int gold; } public enum MCFace { None, Up, Down, East, Weast, North, South }
  9. I resolv. I put accidentaly ;. Script need just , on the last part. Thanks any way
  10. Thanks guys,i reming with one error: Assets/PreviewObjects.cs(75,10): error CS1525: Unexpected symbol `;', expecting `,', `}', or `='
  11. Thanks,is resolv,just the same errors stay on preview.
  12. Again,sorry for spaming,just i try to make a game,and i have errors: Assets/BuildingSystem.cs(39,16): error CS1525: Unexpected symbol `1' Assets/BuildingSystem.cs(39,33): error CS1525: Unexpected symbol `)', expecting `;' or `}' Assets/PreviewObjects.cs(41,8): error CS1525: Unexpected symbol `{' Assets/PreviewObjects.cs(47,12): error CS1519: Unexpected symbol `else' in class, struct, or interface member declaration Assets/PreviewObjects.cs(48,9): error CS9010: Primary constructor body is not allowed Assets/PreviewObjects.cs(55,10): error CS1519: Unexpected symbol `if' in class, struct, or interface member declaration Assets/PreviewObjects.cs(55,24): error CS1519: Unexpected symbol `)' in class, struct, or interface member declaration Assets/PreviewObjects.cs(56,9): error CS9010: Primary constructor body is not allowed Assets/PreviewObjects.cs(56,9): error CS8041: Primary constructor already has a body Assets/PreviewObjects.cs(63,12): error CS1519: Unexpected symbol `else' in class, struct, or interface member declaration Assets/PreviewObjects.cs(64,9): error CS9010: Primary constructor body is not allowed Assets/PreviewObjects.cs(64,9): error CS8041: Primary constructor already has a body Assets/PreviewObjects.cs(71,0): error CS1525: Unexpected symbol `}' Here is my scripts: Build system using System.Collections; using System.Collections.Generic; using UnityEngine; public class BuildingSystem : MonoBehaviour { public List<buildObject> objects = new List<buildObject>(); public buildObject currentobject; private Vector3 currentpos; private Vector3 currentrot; public Transform currentpreview; public Transform cam; public RaycastHit hit; public LayerMask layer; public float offset = 1.0f; public float gridSize = 1.0f; public bool IsBuilding; void Start() { ChangeCurrentBuilding(0); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } void Update() { if (IsBuilding) startPreview(); if (Input.GetButtonDown("Fire1")) Build(); if (Input.GetButtonDown("0") || Input.GetButtonDown("1")) switchCurrentBuilding (); } public void switchCurrentBuilding() { for(int 1 = 0; 1 < 2; 1++) { if (Input.GetKeyDown("" + 1)) ChangeCurrentBuilding(i); } } public void ChangeCurrentBuilding(int cur) { currentobject = objects[cur]; if (currentpreview != null) Destroy(currentpreview.gameObject); GameObject curprev = Instantiate(currentobject.preview, currentpos, Quaternion.Euler (currentrot) ) as GameObject; currentpreview = curprev.transform; } public void startPreview() { if (Physics.Raycast(cam.position, cam.forward, out hit, 10, layer)) { if (hit.transform != this.transform) showPreview(hit); } } public void showPreview(RaycastHit hit2) { currentpos = hit2.point; currentpos -= Vector3.one * offset; currentpos /= gridSize; currentpos = new Vector3(Mathf.Round(currentpos.x), Mathf.Round(currentpos.y), Mathf.Round(currentpos.z)); currentpos *= gridSize; currentpos += Vector3.one * offset; currentpreview.position = currentpos; currentpreview.position = currentpos; if (Input.GetButtonDown("Fire2")) currentrot += new Vector3(0,90,0); currentpreview.localEulerAngles = currentrot; } public void Build() { PreviewObjects PO = currentpreview.GetComponent<PreviewObjects>(); if (PO.IsBuildable) { Instantiate(currentobject.prefab, currentpos, Quaternion.Euler (currentrot) ); } } } [System.Serializable] public class buildObject { public string name; public GameObject prefab; public GameObject preview; public int gold; } -------------------------------------------- BuildPreview: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PreviewObjects : MonoBehaviour { public List<Collider> col = new List<Collider>(); public objectsorts sort; public Material green; public Material red; public bool IsBuildable; public bool second; public PreviewObjects childcol; public Transform graphics; void OnTriggerEnter(Collider other) { if (other.gameObject.layer == 9) col.Add(other); } void OnTriggerExit(Collider other) { if (other.gameObject.layer == 9) col.Remove(other); } void Update() { if(!second) changecolor(); } public void changecolor() { if (sort == objectsorts.fundation { if (col.Count == 0) IsBuildable = true; else IsBuildable = false; } else { if (col.Count == 0 && childcol.col.Count > 0) IsBuildable = true; else IsBuildable = false; } if (IsBuildable) { foreach (Transform child in graphics) { child.GetComponent<Renderer>().material = green; } } else { foreach (Transform child in graphics) { child.GetComponent<Renderer>().material = red; } } } } public enum objectsorts { normal; fundation; floor; } and this is the tutorial:
  13. Thanks,now is work