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.

CakeMonsTv

Member
  • Content Count

    72
  • Joined

  • Last visited

Everything posted by CakeMonsTv

  1. I changed my code a bit and came around the problem, but didnt solve it.
  2. It looks really awesome! I especially like animations and graphics. However, as it was already said before, gun shors might be too loud and I personally think that the gun takes too much of screen space.
  3. Hi. I ran into a problem where my editor window just reopens/restarts out of nowhere. Basically I press Shift 5(CreateFolderItem -> CreateFolder), then I press Shift 3(AddToLinkItem -> AddTolink) and if I press then Shift 4(RevertItem -> Revert), my editor window somehow restarts/reopens and that resets value of textField back to "Task name" https://gyazo.com/43332acf4d8a3590d86e20a25947ddb2 I suspect that it may have something to do with static functions or something. Code: Any help would be much appreciated! Thank you
  4. Everything looks cool except visual effects. That text and everything seems really unprofessional. You can pay someone to do that for like 10$. Nothing much.
  5. I made functions static and variables static. Fixed it.
  6. Hi. So basically I want to call a non-static function from a static function. I have done that by creating a new instance of class named "TemporaryLink" and then calling my non-static function "AddToLink". I have a string a string in TemporaryLink class named "taskName" which has to stay the same after I call AddToLink function. Right now it creates a new instance of TemporaryLink and taskName is the same as if it was never changed. (taskName is being changed with textField in OnGUI function) What should I do to fix this problem? Thank you
  7. Awesome stuff. Those blueprints might come in handy some day for me
  8. Not really my type of game
  9. Can someone people help me fix this issue? Is it a unity bug? https://gyazo.com/5a8efbf35b75ee2c1ecef46e383866ef Everything in my prefab looks centered just fine. Thank you.
  10. Can someone help me with this one? Code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public Transform target; void Start () { } // Update is called once per frame void Update () { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; target.position = hit.point; Vector3 direction = (target.position - transform.position).normalized; Quaternion lookRotation = Quaternion.LookRotation (new Vector3(direction.x, 0, direction.z)); transform.rotation = Quaternion.Slerp (transform.rotation, lookRotation, Time.deltaTime + 5f); } } Thanks!
  11. I Actually went for a totally different approach now. No sorting or anything, just instantiating objects one by one and adding them in list iin that order. (I had to do this sooner or later, since my project required it). Thanks for your time anyway.
  12. I did made a quick look into those articles and i didnt find anything usefull. I thought i could find a more elegant solution like simply searching for object name 1 then 2 then 3 etc. However I will give sorting a more in depth look if I dont find that solution.
  13. How would I add objects to a list in specific order? I first want to add object with name "1" then "2"... (look gyazo image below) Right now I made it so that all those objects will be added but not in that order. ----------------------------------------------------------------------------------------- public List<GameObject> places = new List<GameObject>(); foreach(GameObject placeSearch in GameObject.FindGameObjectsWithTag("place" + team)){ places.Add(placeSearch); } ----------------------------------------------------------------------------------------- Gameobjects to add in order from lowest name number to the highest https://gyazo.com/5be6357ef23dfe8092f68b908419b231 Thanks
  14. Youz made those arms and you sayyou dont know how to use blender well? They are pretty good tho...
  15. Figured it out. So I dont even know what the real reason was but i just changed script for ray shooting and the other reason that im sure of was that you cant put getmousebuttonup insde getmousebutton. void Update () { if (Input.GetMouseButtonDown (1)) { RaycastHit hit; if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hit, 100)) { Pressed = true; places.transform.position = hit.transform.position; } } if (Input.GetMouseButtonUp (1) && (Pressed == true)) { Pressed = false; RaycastHit hit; if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hit, 100)) { float distance = Vector3.Distance(hit.point, places.transform.position); Debug.Log ("distance is" + distance); Pressed = false; } } }
  16. Nope. None of those solutions work... I tried replacing hit3.point with places.transform.position and i also tried putting second if statement out of first one and checking if first one was true before, then the program can call the second one. but it doesnt work. Any other ideas on how i could get the same effect. I mean i think there is a bug in unity's part
  17. I will test that too, but I think I figured it out. The second if statement cannot be called since mouse button 1 isnt pushed at the moment, therefore it cant be in first if statement which requires button to be held all the time. I didn't test it yet tho, ill let you know.
  18. Alright. So, I did what you said and it wrote in a log right after first if statement. Then i put it after second if statement, and it print out anything anymore.
  19. You can put ann object at the end of a car and when you press a button for a flip, the script adds force in certain direction. Therefore the car will do a front flip. Then u can make a script that adjusts so the car always lands properly. (Adding small forces to make car land properly)
  20. I call it from another script attached to my unit. If i click on my unit, it calls selected function. And i checked, sisSelected is true and it still doesnt work.
  21. Hello, So i want to find out distance between position where first ray from input.mousePosition hit terrain (that happens when mouse button 1 is held down) and position from second ray from input.mouseposition hit terrain (that happens when mouse button 1 is let go). For some reason that Getmousebutton doesnt work or something. Really weird. Can someone please help me out. Ive been trying to solve this problem for like 3 hours now cant cant get my head around it... Go to line of code that says THIS PART OF CODE IS NOT WORKING. Thanks using System.Collections; using System.Collections.Generic; using UnityEngine; public class FormationCoNtrol : MonoBehaviour { public GameObject formation; public string formationTag; public GameObject place1; public GameObject place2; public GameObject place3; public GameObject place4; public GameObject place5; public GameObject place6; public GameObject place7; public GameObject place8; public GameObject place9; public GameObject place10; public GameObject place11; public GameObject place12; public Availability isFreeScript; public CameraControl cam; public bool isSelected = false; public string team; public int unitCount = 12; public int placeDist = 0; public GameObject places; // Use this for initialization void Start () { formation = GameObject.FindGameObjectWithTag (formationTag); //GO TO MOUSE CLICK POSITION cam = GameObject.Find ("Main Camera").GetComponent<CameraControl>(); } // Update is called once per frame void Update () { Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); RaycastHit hit; if (Input.GetMouseButtonDown (0) && isSelected == true) { if (Physics.Raycast (ray, out hit, 100)) { if (hit.transform.tag == team) { //if ray hit object, and it has the same name as string team.. } else { isSelected = false; } } } if (Input.GetMouseButtonDown (1) && isSelected == true) { if (Physics.Raycast (ray, out hit, 100)) { formation.transform.position = hit.point; transform.eulerAngles = new Vector3 (0, cam.rot, 0); place1.tag = "place"; place2.tag = "place"; place3.tag = "place"; place4.tag = "place"; place5.tag = "place"; place6.tag = "place"; place7.tag = "place"; place8.tag = "place"; place9.tag = "place"; place10.tag = "place"; place11.tag = "place"; place12.tag = "place"; place1.GetComponent<Availability> ().isFree = true; place2.GetComponent<Availability> ().isFree = true; place3.GetComponent<Availability> ().isFree = true; place4.GetComponent<Availability> ().isFree = true; place5.GetComponent<Availability> ().isFree = true; place6.GetComponent<Availability> ().isFree = true; place7.GetComponent<Availability> ().isFree = true; place8.GetComponent<Availability> ().isFree = true; place9.GetComponent<Availability> ().isFree = true; place10.GetComponent<Availability> ().isFree = true; place11.GetComponent<Availability> ().isFree = true; place12.GetComponent<Availability> ().isFree = true; } } if (Input.GetMouseButton (1) && isSelected == true){ //THIS PART OF CODE IS NOT WORKING Ray ray3 = Camera.main.ScreenPointToRay (Input.mousePosition); RaycastHit hit3; if (Physics.Raycast (ray3, out hit3, 100)) { places.transform.position = hit3.point; } if (Input.GetMouseButtonUp (1)) { Ray ray2 = Camera.main.ScreenPointToRay (Input.mousePosition); //THIS PART OF CODE IS NOT WORKING RaycastHit hit2; if (Physics.Raycast (ray2, out hit2, 100)) { float distance = Vector3.Distance(hit2.point, hit3.point); Debug.Log ("distance is" + distance); //THIS PART OF CODE IS NOT WORKING } } } } public void Selected () { isSelected = true; } }
×
×
  • Create New...