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.

SamedTarik

Member
  • Content Count

    89
  • Joined

  • Last visited

Community Reputation

7 Neutral

About SamedTarik

  • Rank
    Member
  • Birthday November 6

Contact Methods

Profile Information

  • Gender
    Male
  • Location:
    Proudly Türkiye
  • Interests
    Currently, nothing...
  1. Turrets (all of them have navMeshObstacle) are stationary and shooting moving enemies. At first, there is no turret on map, player places them on runtime. And moving enemies (all of them have navMeshAgent) spawn at a certain point and try to reach the goal, it's a classical tower defense game actually. I will upload a picture soon but not sure if a picture can explain the situation since the error happens in a time period.
  2. This question was solved. Thanks for your interest though. http://answers.unity3d.com/questions/981927/need-help-with-xml-reading-class-initialization.html Hi guys, I have an XML scheme like this: <WaveList> <Level levelId = "1"> <Wave waveId = "1"> <Enemy enemyId = "1"> 5 </Enemy> <Enemy enemyId = "2"> 0 </Enemy> <Enemy enemyId = "3"> 0 </Enemy> </Wave> </Level> </WaveList> And I have a class scheme like this (in XML reader code): [XmlRoot ("WaveList")] public class WaveList { [XmlElement("Level")] public List<Level> Levels = new List<Level>(); public class Enemy { [XmlAttribute ("enemyId")] public int Id; public int Amount; } public class Wave { [XmlAttribute ("waveId")] public int Id; //[XmlArray ("Wave"), XmlArrayItem("Enemy")] [XmlElement("Enemy")] public List<Enemy> Enemies = new List<Enemy>(); } public class Level { [XmlAttribute ("levelId")] public int Id; [XmlElement("Wave")] public List<Wave> Waves = new List<Wave>(); } } But when i try to call like this: WaveList.Wave waveToSpawn = new WaveList.Wave(); waveToSpawn = WaveList.Levels[curLevel].Waves[idOfWaveToSpawn]; It gives me a non-static reference error. And i tried with many other combinations and faced different errors. Can anybody give me a tip about how to fetch a wave and enemies in that wave from this code? I hope to end up with something like this: int EnemyId = Levels[1].Waves[3].Enemies[5].Id; int SpawnAmount = Levels[1].Waves[3].Enemies[5].Amount; If my code is rubbish, you may suggest a new code scheme too, of course. Thanks in advance!
  3. It works like a charm until there is one spot left to block path. When I add the turret that actually blocks the path, nothing happens (for the first code, not the second one). But after the path is blocked, it says path is blocked and not allows me to place turrets. I want it to say that and prevent me when i'm trying to place the turret that blocks path, not after i placed it.
  4. Edit: Ah true, i forgot to update the code. That syntax is wrong you were right. But the problem still continues with right syntax. No it's working, the problem is, it's working too late. The script below solved the problem temporarily, but i don't want a solution like this actually. IEnumerator GhostComeAlive () { aGridSelected = false; //first create a temporary gameobject to check if path can complete itself. GameObject gridToCheck = lastGridMousePassedOver; GameObject navMeshChecker = Instantiate(GhostTurretG, gridToCheck.transform.position, gridToCheck.transform.rotation) as GameObject; yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); //calculate the path. NavMeshPath path = new NavMeshPath(); // navMeshValidator.GetComponent<NavMeshAgent>().CalculatePath(navMeshTarget.transform.position, path); // // //now check if it's valid. // if (path.status == NavMeshPathStatus.PathComplete) NavMesh.CalculatePath(navMeshValidator.transform.position, navMeshTarget.transform.position, NavMesh.AllAreas, path); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); if (path.status == NavMeshPathStatus.PathComplete) { Debug.Log ("Path is valid"); //it's valid. let the temporary turret to remain and relase the global object. Destroy(GhostTurretG); GhostTurretG = null; //delete the grid from available grid's list. listOfGridsAvailable.Remove(gridToCheck); //destroy the grid. Destroy(gridToCheck); } else { Debug.Log ("Path is not valid"); //it's invalid. destroy the temporary turret and let global object to remain. Destroy(navMeshChecker); } lastGridMousePassedOver = null; aGridSelected = false; } }
  5. Hi all, I'm trying to make a turret defence game. And i'm trying to check if my navmesh agent can reach to target if i place the turret on selected grid by using bool return of SetDestination. The problem is, it reports that path is blocked when i try to place another turret after i placed the turret actually blocking path. Below is my placement function of turret placement script. Edit: I tried with both SetDestination and CalculatePath. Nothing changed, below is the one i tried with CalculatePath. Edit2: Corrected syntax. Thanks in advance. void GhostComeAlive () { aGridSelected = false; //first create a temporary gameobject to check if path can complete itself. GameObject gridToCheck = lastGridMousePassedOver; GameObject navMeshCheckerTemp = Instantiate(GhostTurretG, gridToCheck.transform.position, gridToCheck.transform.rotation) as GameObject; GameObject navMeshChecker = Instantiate(navMeshCheckerTemp, navMeshCheckerTemp.transform.position, navMeshCheckerTemp.transform.rotation) as GameObject; Destroy (navMeshCheckerTemp); //calculate the path. NavMeshPath path = new NavMeshPath(); // navMeshValidator.GetComponent<NavMeshAgent>().CalculatePath(navMeshTarget.transform.position, path); // // //now check if it's valid. // if (path.status == NavMeshPathStatus.PathComplete) NavMesh.CalculatePath(navMeshValidator.transform.position, navMeshTarget.transform.position, NavMesh.AllAreas, path); //now check if it's valid. if (path.status == NavMeshPathStatus.PathComplete) { Debug.Log ("Path is valid"); //it's valid. let the temporary turret to remain and relase the global object. Destroy(GhostTurretG); GhostTurretG = null; //delete the grid from available grid's list. listOfGridsAvailable.Remove(gridToCheck); //destroy the grid. Destroy(gridToCheck); } else { Debug.Log ("Path is not valid"); //it's invalid. destroy the temporary turret and let global object to remain. Destroy(navMeshChecker); } lastGridMousePassedOver = null; aGridSelected = false; }
  6. Hi mates, I just wanted to ask you for a suggestion about social integration plugins on asset store. I have no budget for it so, i need a free one. I also would be very appreciated too, if you give me a reference that has enough info to write it on my own. Thanks in advance.
  7. For the first of your questions, try to use a global script that has static values for options (that script shouldn't be attached to any gamobject) and then call your options from that script just with "ScriptName.Variable". For the second, you don't have to check screen values, main canvases are able to rescale theirselves with width or height while keeping the aspect or not keeping it (it depends on your choice). To do this, go to options of your main canvas and look for "Ui Scale Mode" under "Canvas Scaler (Script)". Best wishes my mate.
  8. There is a component named "Scroll Rect". I think it does the job doesn't it?
  9. http://armedunity.com/topic/10496-prefab-raycast-mixed-solution-for-ballistics/
  10. if(Input.GetKeyDown("f")&&(isNightVision == false)) { isNightVision = true; NightVisionLight.active = true; } else if(Input.GetKeyDown("f")&&(isNightVision == true)) { isNightVision = false; NightVisionLight.active = false; } instead, if(Input.GetKeyDown("f")) { isNightVision = !isNightvision; NightVisionLight.active = !NightVisionLight.active; }
  11. Hi mates, I'm workin' on an android game project. I need to make a scrollview works with touchscreen, but there is another thing: the list will be updated dynamically by game logic script. I have a button and when i press that button a new line will be added to list. May you explain how to do or give an example? Thanks in advance for any help.
  12. Both are solved. Thanks though. Hi, I'm making an aircraft hud. And i need the angle between the horizon line and the direction aircraft faces to, to make horizon line guide to represent the horizon. And i have another problem, when i write Debug.DrawLine(transform.position, transform.forward*100); it always shows same direction when gamobject is turning on any axis. Thanks in advance.
  13. No no, they work perfectly but i thought it will cause performance issues. Cause i will use them for GUI.
  14. I want rotations on x,y and z axis seperately. Euler angles are suffering from gimbal lock and not always gives same value, rotations neiter. They both change values to negative on a 360 degree flip. Quaternions do the job buy they are too complex. I was just wondering if there is a way to get this without directly using Vector4 and quaternions.
×
×
  • Create New...