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 'help'.



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
    • unity3D | Example Projects
    • unity3D | Scripts
    • unity3D | Shaders
    • unity3D | Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
  • FREE FPS PROJECT
    • FPSKit Download
    • FPSKit Modifications/Tutorials
    • FPSKit WIP/Showcase
    • Discussions / Bug reports
  • SELL | REQUEST
    • Sell
    • Request

Categories

  • Free Projects
  • Free Assets
  • Game Demos

Calendars

  • Community Calendar

Facebook URL


Twitter URL


IndieGoGo URL


Kickstarter URL


IndieDB URL


GreenLight URL


Location:


Interests

Found 183 results

  1. Hi,i Guess Most Of You Know What i Want Based On The Title (i need a FPS World) i want it to have cover and buildings it's ok if it's small and i will list the creator on the credits (if he/she wants) and thanks!
  2. I recently got the TSA and I need help with making the bullets damage the player's health. I am using the FPS Kit 1.5 This is the apply damage part of "BulletScript" IEnumerator ApplyDamage() { //Reduce the enemy's health //Does NOT travel up the heirarchy. //Addthis hit.collider.SendMessage(damageMethodName, damage, SendMessageOptions.DontRequireReceiver); //Produce the appropriate special effect if (hit.transform.tag == hitEffectTag && hitEffect) { GameObject currentHitEffect = (GameObject)(Instantiate(hitEffect, hit.point, myTransform.rotation)); GameObject.Destroy(currentHitEffect, hitEffectDestroyTime); } else if (missEffect) { GameObject currentMissEffect = (GameObject)(Instantiate(missEffect, hit.point + hit.normal * 0.01f, Quaternion.LookRotation(hit.normal))); GameObject.Destroy(currentMissEffect, missEffectDestroyTime); } this.enabled = false; yield return null; //Wait a fram to apply forces as we need to make sure the thing is dead if (hit.rigidbody) hit.rigidbody.AddForceAtPosition(myTransform.forward * bulletForce, hit.point, ForceMode.Impulse); //Linger around for a while to let the trail renderer dissipate (if the bullet has one.) Destroy(gameObject, timeToDestroyAfterHitting); } This is the FPS "HealthScript" #pragma strict @script ExecuteInEditMode() var hitPoints : float; var maxHitPoints : int; var regeneration : boolean = false; var regenerationSpeed : float; var aSource : AudioSource; var painSound : AudioClip; var fallDamageSound : AudioClip; var deadReplacement : Transform; var mySkin : GUISkin; private var radar : GameObject; var damageTexture : Texture; private var t : float = 0.0; private var alpha : float; private var isDead : boolean = false; private var scoreManager : ScoreManager; var camShake : Transform; function Start(){ if(regeneration) hitPoints = maxHitPoints; alpha = 0.0; } function Update(){ if (t > 0.0){ t -= Time.deltaTime; alpha = t; } if(regeneration){ if( hitPoints < maxHitPoints) hitPoints += Time.deltaTime * regenerationSpeed; } } function PlayerDamage (damage : int) { if (hitPoints < 0.0) return; hitPoints -= damage; aSource.PlayOneShot(painSound, 1.0); t = 2.0; if (hitPoints <= 0.0) Die(); } //Picking up MedicKit function Medic (medic : int){ hitPoints += medic; if( hitPoints > maxHitPoints){ var convertToScore : float = hitPoints - maxHitPoints; scoreManager = gameObject.Find("ScoreManager").GetComponent(ScoreManager); scoreManager.addScore(convertToScore); hitPoints = maxHitPoints; } } function Die () { if(isDead) return; isDead = true; if(scoreManager == null) scoreManager = gameObject.Find("ScoreManager").GetComponent(ScoreManager); scoreManager.PlayerDead(); Instantiate(deadReplacement, transform.position, transform.rotation); Destroy(gameObject); } function OnGUI () { GUI.skin = mySkin; GUI.Label (Rect(40, Screen.height - 50,60,60)," + "); GUI.Label (Rect(100, Screen.height - 50,60,60),"" +hitPoints.ToString("F0"), mySkin.customStyles[0]); GUI.color.a = alpha; GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height), damageTexture); } function PlayerFallDamage(dam : float){ PlayerDamage(dam); if(fallDamageSound) aSource.PlayOneShot(fallDamageSound, 1.0); } function Shake(p : float) { var t : float = 1.0; var shakePower : float; while (t > 0.0) { t -= Time.deltaTime; shakePower = t/50; camShake.rotation.x += Random.Range(-shakePower, shakePower); camShake.rotation.y += Random.Range(-shakePower, shakePower); camShake.rotation.z += Random.Range(-shakePower, shakePower); yield; } }
  3. So i am new to unity and i found this FPS-Kit to be really usefull. Sadly i runned into a strange bug that i got rid of but i do not know why. I added some Zombies into the Kit. Then i added Colliders to all bullets to make the Zombies die when get hit. My ZombieScript: ------------------------------------------------------------------------------------------------------- var target: Transform; var health:float = 90; var navComponent: UnityEngine.AI.NavMeshAgent; var anim: Animator; var followDistance: float; // the distance in which to follow the player var minDistance: float; var attackDistance: float; var deadd: int = 0; private var healthScript: HealthScript; function Start() { target = GameObject.FindWithTag("Player").transform; navComponent = this.transform.GetComponent(UnityEngine.AI.NavMeshAgent); anim = GetComponent("Animator"); anim.SetBool("Attack", false); } function Update() { if (deadd == 0){ if (target) { var distanceToTarget = Vector3.Distance(transform.position, target.transform.position); if (distanceToTarget <= followDistance) { if (distanceToTarget <= attackDistance) { anim.SetBool("Attack", true); } else { anim.SetBool("Attack", false); } if (distanceToTarget >= minDistance) { anim.SetBool("Stay", false); navComponent.Resume(); navComponent.SetDestination(target.position); anim.SetFloat("speed", 1); }else { navComponent.Stop(); } } else { anim.SetBool("Stay", true); navComponent.Stop(); } } } } function OnTriggerEnter (col: Collider) { if (col.gameObject.tag == "Projectile") { deadd = 69; navComponent.Stop(); yield WaitForSeconds(0.1); anim.SetBool("Die", true); yield WaitForSeconds(1.12); Destroy(gameObject); } if (col.gameObject.tag == "Player") { healthScript = gameObject.Find("Player").GetComponent(HealthScript); healthScript.Die(); } } -------------------------------------------------------------------------------------------------------- Working fine like 90% of the time. But sometimes after i hit a Zombie the game "Pauses" and i get the following error: MissingReferenceException: The object of type 'SphereCollider' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. ZombieBH+$OnTriggerEnter$69+$.MoveNext () (at Assets/ZombieBH.js:74) UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17) After that i can hit the Pause Button and the game goes on. I only testet this on my m4. I don't use the other weapons in the game atm beside the rpg. Not sure if that happens on rpg too, could not reproduce it as fast as on the m4. I added a "Sphere Collider" on my particle_body as as far as i know this is the part that hits the zombie first. I did not modyfiy the Destroy After Script. But i added colliders to a lot of things to test what exactly kills my zombie. Perhaps i forgot to remove a collider from one object but i could not find anything else with a collider beside particle_untagged. --- I removed the collider from the particle_untagged and as for now the bug stopped to appear. Was the Collider at particle_untagged the reason for my bug? And why? I didn't noticed that when i fire a weapon a particle_untagged appears in my Hierarchy. So i thought this does not have an impact? I'd love to know if this was the reason for my Bug, and if i can improve my Zombie Script. Sorry for my really bad englisch, i am from Germany. Anyway, thank you
  4. Last year I downloaded this project but I do not remember where to download it if someone can help me I appreciate it
  5. photon

    I need help working on a lobby/matchmaking system for my Photon integrated game. Once you've been matched the game starts when full (20 player slot) and isn't joinable after it starts. It would be nice to have players able to select there model before matchmaking and spawning in with that character. If someone can help me out I'd be willing to pay for your code. I'm willing to spend upwards to 60$-100$ Thanks:)
  6. help me to fix that error SendMessage ApplyDamage has no receiver! UnityEngine.Component:SendMessage(String, Object) NewZombieAI:Update() (at Assets/New folder (9)/NewZombieAI.cs:83) This is my NewZombie cs File using UnityEngine; using System.Collections; public class NewZombieAI : MonoBehaviour { Transform target; //the enemy's target public float moveSpeed= 3; //move speed public float rotationSpeed= 3; //speed of turning public float attackRange= 3; // distance within which to attack public float chaseRange= 10; // distance within which to start chasing public float giveUpRange= 20; // distance beyond which AI gives up public float attackRepeatTime = 1.5f; // delay between attacks when within range public GameObject anim; public float maximumHitPoints= 5.0f; public float hitPoints= 5.0f; public GameObject Zombie_New; //public Transform AudioClip attack; private bool chasing= false; private float attackTime; bool checkRay = false; public string idleAnim = "idle"; public string walkAnim = "walk"; public string attackAnim = "attack"; int dontComeCloserRange = 2; private Transform myTransform; //current transform data of this enemy void Awake (){ myTransform = transform; //cache transform data for easy access/preformance ///zombie_New.anim.GetComponent.<Animation>().wrapMode = WrapMode.Loop; Zombie_New.GetComponent<Animation> (). wrapMode = WrapMode.Loop; Zombie_New.GetComponent<Animation> ().wrapMode = WrapMode.Once; //anim.GetComponent.<Animation>()[attackAnim].wrapMode = WrapMode.Once; Zombie_New.GetComponent<Animation> ()[attackAnim].layer = 2; //anim.GetComponent.<Animation>()[attackAnim].layer = 2; //anim.GetComponent.<Animation>().Stop(); Zombie_New.GetComponent<Animation> ().Stop(); } void Start (){ target = GameObject.FindWithTag("Player").transform; } void Update (){ // check distance to target every frame: float distance = (target.position - myTransform.position).magnitude; if (distance < dontComeCloserRange){ moveSpeed = 0; //anim.GetComponent.<Animation>()[idleAnim]; Zombie_New.GetComponent<Animation> ().Play(idleAnim); //anim.GetComponent.<Animation>().CrossFade(idleAnim); Zombie_New.GetComponent<Animation> ().CrossFade(idleAnim); }else{ moveSpeed = Random.Range(2, 3); //anim.GetComponent.<Animation>().CrossFade(walkAnim); Zombie_New.GetComponent<Animation> ().CrossFade(walkAnim); } if (chasing) { //move towards the player myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime; //rotate to look at the player myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime); transform.eulerAngles = new Vector3(0.0f, transform.eulerAngles.y, 0.0f); // give up, if too far away from target: if (distance > giveUpRange) { chasing = false; } // attack, if close enough, and if time is OK: if (distance < attackRange && Time.time > attackTime) { //anim.GetComponent.<Animation>()[attackAnim].speed = 4.0f; Zombie_New.GetComponent<Animation> ()[attackAnim].speed = 1.0f; //anim.GetComponent.<Animation>().CrossFade(attackAnim); Zombie_New.GetComponent<Animation> ().CrossFade(attackAnim); target.SendMessage( "ApplyDamage", maximumHitPoints); attackTime = Time.time + attackRepeatTime; //GetComponent.<AudioSource>().PlayOneShot(attack, 1.0f / GetComponent.<AudioSource>().volume); } } else { // not currently chasing. //anim.GetComponent.<Animation>() [idleAnim].speed = 4; Zombie_New.GetComponent<Animation> ()[idleAnim].speed = 4; //anim.GetComponent.<Animation>().CrossFade(idleAnim); Zombie_New.GetComponent<Animation> ().CrossFade(idleAnim); // start chasing if target comes close enough if (distance < chaseRange) { chasing = true; } } } void OnDrawGizmosSelected (){ Gizmos.color = Color.yellow; Gizmos.DrawWireSphere (transform.position, attackRange); Gizmos.color = Color.red; Gizmos.DrawWireSphere (transform.position, chaseRange); } } NewZombieAI.cs
  7. free unity project is provided by armedunity name is Au Fpskit 1.5 I want to know how to add enemy to that project please help guys
  8. Hello i have probleme . on my game i want to add AI , i have tactical shooter AI but i dont know how to integrate this asset on my game , i have try but i never do damage to the AI . Somone can help me pls ? Thank.Insert other media
  9. Hello, i'm trying to make a RPG game with multiplayer, not so hard with what i can program so far. But what im really struggling about is Third Person controller Animator help, i dont want to use the default TPC (Third Person Controller) that comes with Unity Standard Assets. I want to create my own, by using the Male Locomotion pack from Mixamo.com, then i search around on how to make a simple third person controller, and then there are a lot of good videos. But one problem is in every video, the problem is that i dont want to use the Walk_Turn or Run_Turn animations for turning while walking or running, i want to have a free camera so if i change my view to the right with right mouse button then the character will run or walk that direction. The camera of course follows the character behind. So this is what i really am asking help for : -Simple Animator with c# script -FreeCameraLook.cs script -Character walking the direction the camera is pointing (Can only run / walk on the X axis or Z axis, not up or down) Thanks in advance if someone find good tutorials and post them down in the comment section, and of course thanks a lot for those who try to help!
  10. Hello world. Im here to ask one question and hopefully people will write back and take their time to reed this. So my question to the programmers out there is, whats, where and how is the best way to learn Unity C# programming. When i say C# Programming i also mean Network Programming, it is completly okey and ill be really thankful if there isn't a really good unity3d network programming tutorial but only the other type of programming. Anything helps out! I have searched around a lot a lot of to learn programming networking, but don't find so much useful tutorials. I can program a little bit, i have made a basic FPS game by my self and it is really cool in my opinion, but it is boring to play a game where you can't do much but walk around and shoot Ai. So i really wanted to learn Network Programming. Then came this beautiful thing called Unet, or maybe it is old, i dont know, when i say Unet i mean all the new networking components. My experience with multiplayer : The only thing i have completed by using Unet, is making a player join by the NetworkManager / NetworkManagerHUD and walk around and look around in a FPS type of view. And it worked / works. That wasn't so advanced and hard to program, so i thought that it wouldn't be so hard to program in other things like shooting, switching weapons and so on. Oh God it was. So then i ran into this type of thing called [Command] //or Cmd This was new, and it will be new and never be understood by me. I am talking about a lot of other commands and words in Unet programming, but these are the first ones i ran into. So my question is, is there really any good and useful tutorials / streams / courses or whatever it can be, that will help you out in Unity3D C# Programming and Unity3D C# Network Programming ? Thanks in advance for reading all this, thank you for your time and i hope you have a good answer and i hope you have a wonderful day
  11. buddy i need to know how to change FPS hands to FPS model like "Max" with full body?
  12. Guys i have found a nice template but i don't know is this a fake/Virus downlod? can one of you test it? Link to the site: REMOVED Thanks
  13. Hi guys and girls ! I have a problem with... low poly works. This type modelling is wrong for low-polygon ? MAYA I want to make cartoony looking environments but ı don't understand something or... Why can't make soft edge for low poly or black sections isn't problem or ı don't understand how to make low poly ? We using hard surface ? Yes ım never make low poly works !!! seriously Thank you...
  14. Hi, I wanna remove the function that goes over, what code should I remove/change on FPSController.cs? https://youtu.be/CGDkDKmpcJA
  15. Can someone tell me how do i repeat something like a function each X second? Till now i ve been using something like this but it is not very "professional" private float totalTime = 3; private float countdown = 3; //I used this to repeat something each 3 sec void Update() { countDown -= Time.Deltatime; if(countDown <= totalTime) { countDown = totalTime; Debug.Log("Hello World"); } } Help please, im just a begginer
  16. I did something to cause this i think but i don't know what... I was messing around with the lights i think
  17. So I freshly installed Windows, and downloaded Unity. I installed it and restarted my computer, and when I went to create a new project, it is a dark theme but I have personal edition What could be causing this?
  18. Hello everyone! I am having a bit of trouble with this Inventory System. My game is going fine but the only problem is that playing it would be pointless because the Inventory doesn't even save! If anyone knows how to implement saving please help! and I know the script is big sorry . Thanks SCRIPT : using UnityEngine; using System.Collections; using System.Collections.Generic; public class Player : MonoBehaviour { public Transform myTransform; public Transform myBody; public Transform myHips; public Transform mySpine; public Transform myCamera; public Transform mySpawnpoint; public List<Transform> myItems; private Multiplayer multiplayer; private Transform[] myArray; private CharacterMotor myCharMotor; public Texture2D[] CrossHairs; public Inventory myInventory; public GameObject[] AttackPrefabs; private ItemDatabase db; public float nextUseTime; public float myHealth; public const float MAX_HEALTH = 100; public float healthRegen; public float prevHealth; public bool hitted = false; public bool bleeding = false; public const float MAX_STATS = 100; public float myHunger; public float hungerTake; public float myThirst; public float thirstTake; public float arrowForce = 600.0f; private Texture2D texture_background; private Texture2D texture_hotbar; private Texture2D texture_inventory; private Texture2D texture_crafting; private Texture2D image; private Texture2D recipes; public bool isInventoryOpen = false; public float screenSizeMultiplier = 0.6f; public InventoryItem selectedItem; public Vector2 selectedPos; private Vector2 btnSize; private Vector2 mousePos; public GUISkin skin; void Start() { //Load myObjects myArray = new Transform[5]; myItems = new List<Transform>(); myTransform = transform; myArray[0] = myTransform; myBody = myTransform.FindChild("body"); myArray[1] = myBody; myHips = myBody.FindChild("Hips"); myArray[2] = myHips; mySpine = myHips.FindChild("Spine").FindChild("Spine1").FindChild("Spine2"); myArray[3] = mySpine; myCamera = mySpine.FindChild("MainCamera"); myArray[4] = myCamera; mySpawnpoint = myCamera.FindChild("Spawnpoint"); myCharMotor = myTransform.GetComponent<CharacterMotor>(); /***********************************/ //Select all items Transform itemHolder = mySpine.FindChild("RightShoulder").FindChild("RightArm").FindChild("RightForeArm").FindChild("RightHand").FindChild("Items"); foreach(Transform c in itemHolder) { myItems.Add(c); } EnableDisableItems(-1, false); //Disable all items. //Set default health options myHealth = 100; healthRegen = 1.3f; prevHealth = 100; //Set default hunger and thirst myHunger = 100; myThirst = 100; thirstTake = 0.1f; hungerTake = 0.01f; //Load Crosshairs CrossHairs = new Texture2D[3]; CrossHairs[0] = (Texture2D)Resources.Load("Textures/Crosshairs/Crosshair1"); //Default crosshair //Load GUI Textures texture_background = (Texture2D)Resources.Load("Textures/HUD/background"); texture_hotbar = (Texture2D)Resources.Load("Textures/HUD/hotbar"); texture_inventory = (Texture2D)Resources.Load("Textures/HUD/inventory"); texture_crafting = (Texture2D)Resources.Load("Textures/HUD/crafting"); recipes = (Texture2D)Resources.Load("Textures/HUD/recipes"); //Setup new Inventory myInventory = new Inventory(); selectedItem = InventoryItem.NULL; //Get db db = GameObject.Find("MPManager").GetComponent<ItemDatabase>(); multiplayer = GameObject.Find("MPManager").GetComponent<Multiplayer>(); btnSize = new Vector2(70.5f, 70.5f); if(GetComponent<NetworkView>().isMine) { InvokeRepeating("ThirstAndHungerController", 0, 1); } InvokeRepeating("UpdateSoundSettings", 0, 3); } void Update() { HealthController(); EquipmentController(); if(GetComponent<NetworkView>().isMine) { EquipmentUse(); } AnimationController(); } void UpdateSoundSettings() { GetComponent<AudioSource>().volume = multiplayer.GetComponent<AudioSource>().volume; } void HealthController() { if (myHealth < MAX_HEALTH) { if(bleeding) { myHealth -= healthRegen * Time.deltaTime; } else { myHealth += healthRegen * Time.deltaTime; } } if(myHunger > 80 && myThirst > 80) { healthRegen = 2.2f; } if (myHealth > MAX_HEALTH) { myHealth = MAX_HEALTH; } if (myHealth < 1 && GetComponent<NetworkView>().isMine) { GameObject.Find("SpawnManager").GetComponent<SpawnManager>().isDead = true; Network.RemoveRPCs(Network.player); GetComponent<NetworkView>().RPC("DestroySelf", RPCMode.All); } if(hitted) { GetComponent<NetworkView>().RPC("UpdateMyCurrentHealthEverywhere", RPCMode.Others, myHealth); hitted = false; } if (myHealth > 0 && GetComponent<NetworkView>().isMine) { if (myHealth != prevHealth) { GetComponent<NetworkView>().RPC("UpdateMyHealthEverywhere", RPCMode.AllBuffered, myHealth); } } } void ThirstAndHungerController() { if(myHunger > 0) { myHunger -= hungerTake; } else { bleeding = true; } /* if(myThirst > 0) { myThirst -= thirstTake; } else { bleeding = true; } * */ if(myThirst > 0 && myHunger > 0) { bleeding = false; } } void ReloadAmmo() { InventoryItem item = myInventory.getItemByPosition(myInventory.curItem); if(item.item.getType().Equals("Gun")) { int ammoLeft = 20 - item.status[2]; if(item.status[3] > ammoLeft) { item.status[2] += ammoLeft; item.status[3] -= ammoLeft; } else { item.status[2] += item.status[3]; item.status[3] = 0; } } } public void KickBack() { transform.position = Vector3.Lerp(transform.position, transform.position - (transform.forward - transform.up), 1); } void EquipmentUse() { if( Screen.lockCursor ) { if (Input.GetButton("Fire1") && Time.time > nextUseTime) { InventoryItem item = myInventory.getItemByPosition(myInventory.curItem); if(item.item.getType().Equals("Gun")) { //Check ammo if(item.status[2] < 1) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "ReloadGun", true, 1f); Invoke("ReloadAmmo", 1f); return; } else { item.status[2]--; } } else if(item.item.getType().Equals("Consumable")) { if(item.item.getDescription().Contains("(Food)")) { if(myHunger < MAX_STATS) myHunger += item.item.getDamage(); } else if (item.item.getDescription().Contains("(Drink)")) { if (myHunger < MAX_STATS) myThirst += item.item.getDamage(); } myInventory.myItems[(int)myInventory.curItem.x, (int)myInventory.curItem.y] = InventoryItem.NULL; myInventory.RemoveFromHotbar(item); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } else if (item.item.getType().Equals("Placeable")) { //myInventory.myItems[(int)myInventory.curItem.x, (int)myInventory.curItem.y] = InventoryItem.NULL; //myInventory.RemoveFromHotbar(item); //selectedItem = InventoryItem.NULL; //selectedPos = new Vector2(29, 11); } else if (item.item.getType().Equals("Bow")) { //Check ammo if (item.status[2] < 1) { Invoke("ReloadAmmo", 1f); return; } else { item.status[2]--; } } nextUseTime = Time.time + item.item.getUseDelay(); string animName = item.item.getUseAnimation(); GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, animName.Trim(), true, item.item.getAnimationSpeed()); GetComponent<NetworkView>().RPC( "SpawnAttack", RPCMode.All, mySpawnpoint.position, Quaternion.Euler(mySpawnpoint.eulerAngles.x + 90, mySpawnpoint.eulerAngles.y, 0), transform.name, item.item.ID); } if(Input.GetButtonDown("Reload")) { InventoryItem item = myInventory.getItemByPosition(myInventory.curItem); if (item.item.getType().Equals("Gun")) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "ReloadGun", true, 1f); Invoke("ReloadAmmo", 1f); } } if (Input.GetButton("Fire2")) { myCamera.GetComponent<Camera>().fieldOfView = Mathf.Lerp(myCamera.GetComponent<Camera>().fieldOfView, 40f, 2f * Time.deltaTime); } else { myCamera.GetComponent<Camera>().fieldOfView = Mathf.Lerp(myCamera.GetComponent<Camera>().fieldOfView, 60f, 2f * Time.deltaTime); } } } public void DeletePlaceable() { InventoryItem item = myInventory.getItemByPosition(myInventory.curItem); myInventory.myItems[(int)myInventory.curItem.x, (int)myInventory.curItem.y] = InventoryItem.NULL; myInventory.RemoveFromHotbar(item); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } void EquipmentController() { InventoryItem curItem = myInventory.getItemByPosition(myInventory.curItem); int goID; if(curItem.Equals(InventoryItem.NULL)) { goID = 0; } else { goID = myInventory.getItemByPosition(myInventory.curItem).item.ID; } if (myItems[goID] != null) { EnableDisableItems(-1, false); EnableDisableItems(goID, true); } else { EnableDisableItems(-1, false); myInventory.curItem = new Vector2(0,0); } if(GetComponent<NetworkView>().isMine) { if (Input.GetMouseButtonDown(1) && !selectedItem.Equals(InventoryItem.NULL)) { selectedItem = InventoryItem.NULL; } if (Input.GetKeyDown(KeyCode.Alpha1)) { myInventory.curItem = myInventory.myHotbar[0]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if (Input.GetKeyDown(KeyCode.Alpha2)) { myInventory.curItem = myInventory.myHotbar[1]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if (Input.GetKeyDown(KeyCode.Alpha3)) { myInventory.curItem = myInventory.myHotbar[2]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if (Input.GetKeyDown(KeyCode.Alpha4)) { myInventory.curItem = myInventory.myHotbar[3]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if (Input.GetKeyDown(KeyCode.Alpha5)) { myInventory.curItem = myInventory.myHotbar[4]; GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SwitchItem", true, 1.0f); } if(Input.GetButtonDown("Friendly")) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "Friendly", true, 1.0f); } if(Input.GetButtonDown("Inventory")) { isInventoryOpen = !isInventoryOpen; multiplayer.EnableDisablePlayer(!isInventoryOpen); if (isInventoryOpen) multiplayer.gameState = Multiplayer.GameState.INVENTORY; else multiplayer.gameState = Multiplayer.GameState.PLAYING; } GetComponent<NetworkView>().RPC("SendCurrentItem", RPCMode.Others, (int)myInventory.curItem.x, (int)myInventory.curItem.y); } } void EnableDisableItems(int index, bool enable) { if(index == -1) { for (int i = 0; i < myItems.Count; i++) { myItems[i].gameObject.SetActive(enable); } } else { myItems[index].gameObject.SetActive(enable); } } int GetItemIndex(string GameObjectName) { for (int i = 0; i < myItems.Count; i++) { if (myItems[i].gameObject.name.Equals(GameObjectName)) return i; } return -1; } void OnGUI() { if(GetComponent<NetworkView>().isMine) { mousePos = new Vector2 (Input.mousePosition.x, -Input.mousePosition.y + Screen.height); GUI.skin = skin; if(multiplayer.gameState.Equals(Multiplayer.GameState.PLAYING) || multiplayer.gameState.Equals(Multiplayer.GameState.INVENTORY)) { //Draw Crosshair GUI.DrawTexture(new Rect(Screen.width / 2 - CrossHairs[0].width / 2, Screen.height / 2 - CrossHairs[0].height / 2, CrossHairs[0].width, CrossHairs[0].height), CrossHairs[0]); //Draw Hotbar and Inventory GUIController(); } if (Input.GetButton("Recipes")) { GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), recipes, ScaleMode.StretchToFill); } } } void GUIController() { if(isInventoryOpen) { //Draw Background GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), texture_background, ScaleMode.StretchToFill); //Draw Crafting float craft_w = texture_crafting.width * screenSizeMultiplier; float craft_h = texture_crafting.height * screenSizeMultiplier; Rect craftRect = new Rect(Screen.width / 2 - craft_w / 2, 0, craft_w, craft_h); GUI.DrawTexture(craftRect, texture_crafting); int btnsToShow = 1; for (int i = 0; i < myInventory.craftList.Count; i++) { if(!myInventory.craftList[i].Equals(InventoryItem.NULL)) { btnsToShow++; } } if(GUI.Button(new Rect(Screen.width - 100, 10, 100, 50), "Clear")) { myInventory.ClearCraftList(); } if (btnsToShow > 4) { btnsToShow = 4; } if(btnsToShow > 1) { //Lets see the recipe so far InventoryItem itemToCraft = db.getItemForRecipe(myInventory.craftList); if(!itemToCraft.Equals(InventoryItem.NULL)) { Vector2 startPos = new Vector2(craftRect.x + 12f * screenSizeMultiplier, craftRect.y + 60f * screenSizeMultiplier); Vector2 btnPos = startPos + new Vector2(btnSize.x * screenSizeMultiplier * 5 + (12f * screenSizeMultiplier * 5), 0); Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + itemToCraft.item.ID); if (GUI.Button(new Rect(btnPos.x, btnPos.y, (btnSize.x) * screenSizeMultiplier, (btnSize.y - 10f) * screenSizeMultiplier), image)) { RemoveItemNetwork(db.getRecipeToRemove(itemToCraft, myInventory.craftList)); //Take the used resources myInventory.ClearCraftList(); //Clear craft list if(AddItemNetwork(itemToCraft)) { Debug.Log("Added Item"); } itemToCraft = InventoryItem.NULL; } } } for (int i = 0; i < btnsToShow; i++) { Vector2 startPos = new Vector2(craftRect.x + 12f * screenSizeMultiplier, craftRect.y + 60f * screenSizeMultiplier); Vector2 btnPos = startPos + new Vector2(btnSize.x * screenSizeMultiplier * i + (12f * screenSizeMultiplier * i), 0); if(myInventory.craftList[i].Equals(InventoryItem.NULL)) { if (GUI.Button(new Rect(btnPos.x, btnPos.y, (btnSize.x) * screenSizeMultiplier, (btnSize.y - 10f) * screenSizeMultiplier), "")) { if (!selectedItem.Equals(InventoryItem.NULL)) { myInventory.craftList[i] = selectedItem ; selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } } } else { Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + myInventory.craftList[i].item.ID); GUI.DrawTexture(new Rect(btnPos.x, btnPos.y, (btnSize.x) * screenSizeMultiplier, (btnSize.y - 10f) * screenSizeMultiplier), image); } } //Draw Inventory float inv_w = texture_inventory.width * screenSizeMultiplier; float inv_h = texture_inventory.height * screenSizeMultiplier; Rect windowRect = new Rect(Screen.width / 2 - inv_w / 2, Screen.height / 2 - inv_h / 2, inv_w, inv_h); GUI.DrawTexture(windowRect, texture_inventory); //Drop Item if(!selectedItem.Equals(InventoryItem.NULL) && !selectedItem.item.getType().Equals("Placeable")) { if(GUI.Button(new Rect(10, 10, 100, 50), "Drop")) { if(selectedItem.status[0] > 1) //If stackable { selectedItem.status[0]--; } else { myInventory.myItems[(int)selectedPos.x, (int)selectedPos.y] = InventoryItem.NULL; myInventory.RemoveFromHotbar(selectedItem); } Network.Instantiate((Object)Resources.Load("Prefabs/Drop/" + selectedItem.item.Name), myTransform.position, Quaternion.identity, 2); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } } //Draw Inventory Items for (int y = 0; y < myInventory.myItems.GetLength(1); y++) { for (int x = 0; x < myInventory.myItems.GetLength(0); x++) { Vector2 startPos = new Vector2(windowRect.x + 12f * screenSizeMultiplier, windowRect.y + 75f * screenSizeMultiplier); Vector2 pos = new Vector2(x, y); Vector2 btnPos = startPos + new Vector2(btnSize.x * screenSizeMultiplier * x + (12f * screenSizeMultiplier * x), btnSize.y * screenSizeMultiplier * y + (12f * screenSizeMultiplier * y)); if(myInventory.unlocked[x,y]) { if(myInventory.myItems[x,y].Equals(InventoryItem.NULL)) { //Trocar com o fists if (GUI.Button(new Rect(btnPos.x, btnPos.y, btnSize.x * screenSizeMultiplier, btnSize.y * screenSizeMultiplier), "")) { if(!selectedItem.Equals(InventoryItem.NULL)) { if (!selectedPos.Equals(new Vector2(29, 11))) myInventory.UpdateHotbar(selectedPos, new Vector2(x,y)); myInventory.myItems[x, y] = selectedItem; selectedItem = InventoryItem.NULL; if(!selectedPos.Equals(new Vector2(29, 11))) myInventory.myItems[(int)selectedPos.x, (int)selectedPos.y] = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } } } else { InventoryItem item = myInventory.myItems[x, y]; image = (Texture2D)Resources.Load("Textures/Items/" + item.item.ID); if(!selectedItem.Equals(InventoryItem.NULL)) { //We have a selected item, and we want to replace with other item. if (GUI.Button(new Rect(btnPos.x, btnPos.y, btnSize.x * screenSizeMultiplier, btnSize.y * screenSizeMultiplier), image)) { myInventory.myItems[(int)selectedPos.x, (int)selectedPos.y] = item; myInventory.myItems[x, y] = selectedItem; selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } if (item.status[1] != 0) //If its stackable { GUI.Label(new Rect(btnPos.x + (btnSize.x * screenSizeMultiplier / 2), btnPos.y + btnSize.y * screenSizeMultiplier - 20, 30, 20), "x" + item.status[0].ToString()); } } else { //We want to choose an item if (GUI.Button(new Rect(btnPos.x, btnPos.y, btnSize.x * screenSizeMultiplier, btnSize.y * screenSizeMultiplier), image)) { selectedItem = item; selectedPos = new Vector2(x, y); } if (item.status[1] != 0) //If its stackable { GUI.Label(new Rect(btnPos.x + (btnSize.x * screenSizeMultiplier / 2), btnPos.y + btnSize.y * screenSizeMultiplier - 20, 30, 20), "x" + item.status[0].ToString()); } } } } } } //Draw Hotbar with buttons float hotbar_w = texture_hotbar.width * screenSizeMultiplier; float hotbar_h = texture_hotbar.height * screenSizeMultiplier; GUI.DrawTexture(new Rect( Screen.width / 2 - hotbar_w / 2, Screen.height - hotbar_h, hotbar_w, hotbar_h), texture_hotbar); for(int i = 0; i < myInventory.myHotbar.Length; i++) { Vector2 hotbarItem = myInventory.myHotbar[i]; float img_w = 87 * screenSizeMultiplier; float img_h = 87 * screenSizeMultiplier; float base_x = Screen.width / 2 - hotbar_w / 2 + (12 * screenSizeMultiplier) + (img_w * i) + (12 * screenSizeMultiplier * i); float base_y = Screen.height - hotbar_h + 12; InventoryItem item = myInventory.getItemByPosition(myInventory.myHotbar[i]); Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + item.item.ID); if(!hotbarItem.Equals(new Vector2(29, 11))) { if(item.item.ID != 0) { if (GUI.Button(new Rect(base_x, base_y, img_w, img_h), image)) { if(!selectedItem.Equals(InventoryItem.NULL)) { myInventory.myHotbar[i] = myInventory.getItemPosition(item.item); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } else { if(Event.current.button == 1) { myInventory.myHotbar[i] = new Vector2(29, 11); } } } } } else { if (GUI.Button(new Rect(base_x, base_y, img_w, img_h), image)) { if(!selectedItem.Equals(InventoryItem.NULL)) { myInventory.myHotbar[i] = myInventory.getItemPosition(selectedItem.item); selectedItem = InventoryItem.NULL; selectedPos = new Vector2(29, 11); } } } } if(!selectedItem.Equals(InventoryItem.NULL)) { Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + selectedItem.item.ID); GUI.Box(new Rect(mousePos.x, mousePos.y, btnSize.x, btnSize.y), image); } //Debug /* for (int y = 0; y < myInventory.myItems.GetLength(1); y++) { for (int x = 0; x < myInventory.myItems.GetLength(0); x++) { GUI.Label(new Rect(0 + x * 100, 0 + y * 20, 100, 20), myInventory.myItems[x, y].item.Name); } } for(int i = 0; i < myInventory.myHotbar.Length; i++) { GUI.Label(new Rect(0 + i * 100, 150, 100, 20), myInventory.myHotbar[i].ToString()); } GUI.Label(new Rect(0, 170, 500, 20), selectedItem.item.Name + " " + selectedPos.ToString()); * */ } else { //Draw Hotbar float hotbar_w = texture_hotbar.width * screenSizeMultiplier; float hotbar_h = texture_hotbar.height * screenSizeMultiplier; GUI.DrawTexture(new Rect( Screen.width / 2 - hotbar_w / 2, Screen.height - hotbar_h, hotbar_w, hotbar_h), texture_hotbar); //Draw Hotbar Items for (int i = 0; i < myInventory.myHotbar.Length; i++) { float img_w = 87 * screenSizeMultiplier; float img_h = 87 * screenSizeMultiplier; float base_x = Screen.width / 2 - hotbar_w / 2 + (12 * screenSizeMultiplier) + (img_w * i) + (12 * screenSizeMultiplier * i); float base_y = Screen.height - hotbar_h + 12; InventoryItem item = myInventory.getItemByPosition(myInventory.myHotbar[i]); //Item in the hotbar Texture2D image = (Texture2D)Resources.Load("Textures/Items/" + item.item.ID); GUI.DrawTexture(new Rect(base_x, base_y, img_w, img_h), image); } } } void AnimationController() { //Walk Animation if(myCharMotor.movement.velocity.magnitude >= 2) { if(!myHips.GetComponent<Animation>().isPlaying) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 2, "Walk", true, 1.0f); } } //Weapons if(!mySpine.GetComponent<Animation>().isPlaying) { if (myInventory.getItemByPosition(myInventory.curItem).Equals(InventoryItem.NULL)) { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleFists", true, 1.0f); } else { if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("MeleeDual")) //Dual Wield { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("MeleeSpear")) //Spear Wield { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "SpearIdle", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("MeleeOne")) //One hand weapon { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "OneHandIdle", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Item")) //Item Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Gun")) //Gun Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleGunDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Bow")) //Bow Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Consumable")) //Bow Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else if (myInventory.getItemByPosition(myInventory.curItem).item.Type.Equals("Placeable")) //Bow Idle { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleDualHands", true, 1.0f); } else { GetComponent<NetworkView>().RPC("NetworkAnimation", RPCMode.All, 3, "IdleFists", true, 1.0f); } } } } void SpawnSound(Vector3 pos, string clipName) { GameObject go = (GameObject)Resources.Load("Prefabs/General/AudioSpawner"); go = Instantiate(go, pos, Quaternion.identity) as GameObject; go.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Sounds/" + clipName)); } IEnumerator InstantiateAttack(Vector3 pos, Quaternion rot, string owner, int itemID, float delay) { yield return new WaitForSeconds(delay); SpawnSound(transform.position, db.Items[itemID].getAudioName()); if (!pos.Equals(mySpawnpoint.position)) { pos = mySpawnpoint.position; } if(!rot.Equals(Quaternion.Euler(mySpawnpoint.eulerAngles.x + 90, mySpawnpoint.eulerAngles.y, 0))) { rot = Quaternion.Euler(mySpawnpoint.eulerAngles.x + 90, mySpawnpoint.eulerAngles.y, 0); } GameObject go = Instantiate(AttackPrefabs[db.Items[itemID].getPrefabAttack()], pos, rot) as GameObject; MeleeAttack m = go.GetComponent<MeleeAttack>(); if(m != null) { m.owner = owner; m.weaponID = itemID; } else { go.GetComponent<Arrow>().owner = owner; go.GetComponent<Arrow>().weaponID = itemID; go.GetComponent<Rigidbody>().AddForce(mySpawnpoint.forward * arrowForce); } } public bool AddItemNetwork(InventoryItem item) { Vector2 slot = myInventory.getNextAvailableSlot(); if(myInventory.AddItem(item)) { GetComponent<NetworkView>().RPC("AddItemOverNetwork", RPCMode.OthersBuffered, item.item.ID, (int)slot.x, (int)slot.y); return true; } else { return false; } } public bool RemoveItemNetwork(InventoryItem item, int qtd) { Vector2 slot = myInventory.getItemPosition(item.item); if (myInventory.RemoveItem(item, qtd)) { GetComponent<NetworkView>().RPC("RemoveItemOverNetwork", RPCMode.OthersBuffered, item.item.ID, qtd); return true; } else { return false; } } public bool RemoveItemNetwork(List<InventoryItem> item) { for(int x = 0; x < item.Count; x++) { Vector2 slot = myInventory.getItemPosition(item[x].item); if (myInventory.RemoveItem(item[x], item[x].status[0])) { GetComponent<NetworkView>().RPC("RemoveItemOverNetwork", RPCMode.OthersBuffered, item[x].item.ID, item[x].status[0]); } } return true; } /* * RPC's */ [RPC] void SpawnAttack(Vector3 pos, Quaternion rot, string owner, int itemID) { StartCoroutine( InstantiateAttack( pos, rot, owner, itemID, db.Items[itemID].getAttackSpawnDelay() )); } [RPC] void NetworkAnimation(int trans, string anim, bool cf, float AnimSpeed) { if(myArray[trans] != null) myArray[trans].GetComponent<Animation>()[anim].speed = AnimSpeed; if (cf) //Crossfade? { myArray[trans].GetComponent<Animation>().CrossFade(anim); } else { myArray[trans].GetComponent<Animation>().Play(anim); } } [RPC] void SendCurrentItem(int x, int y) { myInventory.curItem = new Vector2(x, y); } [RPC] void DestroySelf() { Destroy(gameObject); } [RPC] void UpdateMyHealthEverywhere( float hp) { prevHealth = hp; } [RPC] void UpdateMyCurrentHealthEverywhere(float hP) { myHealth = hP; } [RPC] public void AddItemOverNetwork(int itemID, int x, int y) { multiplayer.GetComponent<Console>().Write("AddItemOverNetwork Called in player " + gameObject.name); Item i = GameObject.Find("MPManager").GetComponent<ItemDatabase>().getItemByID(itemID); myInventory.myItems[x, y] = new InventoryItem(i, InventoryItem.DefaultStatus(false, 0, 1)); multiplayer.GetComponent<Console>().Write("Item " + i.ToString() + " added to " + new Vector2(x,y).ToString() + " on player " + gameObject.name); } [RPC] public void RemoveItemOverNetwork(int itemID, int qtd) { multiplayer.GetComponent<Console>().Write("RemoveItemOverNetwork Called in player " + gameObject.name); Item i = GameObject.Find("MPManager").GetComponent<ItemDatabase>().getItemByID(itemID); InventoryItem itemToDelete = new InventoryItem(i, InventoryItem.DefaultStatus(false, 1, 1)); if (myInventory.RemoveItem(itemToDelete, qtd)) { multiplayer.GetComponent<Console>().Write("Item " + i.ToString() + " removed on player " + gameObject.name); } else { multiplayer.GetComponent<Console>().Error("Item couldn't be removed!"); } } } public class Inventory { public Vector2 curItem; public InventoryItem[,] myItems; public bool[,] unlocked; public Vector2[] myHotbar; public int maxItems; public List<InventoryItem> craftList; public Inventory() { curItem = new Vector2(29, 11); myItems = new InventoryItem[6, 5]; unlocked = new bool[6, 5]; craftList = new List<InventoryItem>(); myHotbar = new Vector2[5]; maxItems = 10; ItemDatabase db = GameObject.Find("MPManager").GetComponent<ItemDatabase>(); setupArray(); OpenSlots(12); AddItem(new InventoryItem(db.getItemByName("WoodAxe"), InventoryItem.DefaultStatus(false, 0, 1))); } public void UpdateHotbar(Vector2 old, Vector2 newpos) { for (int i = 0; i < myHotbar.Length; i++) { if (myHotbar[i].Equals(old)) myHotbar[i] = newpos; } } public void ClearCraftList() { for (int i = 0; i < craftList.Count; i++) { craftList[i] = InventoryItem.NULL; } } public void setupArray() { for (int i = 0; i < myHotbar.Length; i++) { myHotbar[i] = new Vector2(29, 11); } for (int y = 0; y < myItems.GetLength(1); y++) { for (int x = 0; x < myItems.GetLength(0); x++) { myItems[x, y] = InventoryItem.NULL; } } for (int i = 0; i < 4; i++) { craftList.Add(InventoryItem.NULL); } } public InventoryItem getItemByPosition(Vector2 pos) { if (isValid(pos)) { if (!myItems[(int)pos.x, (int)pos.y].Equals(InventoryItem.NULL)) { return myItems[(int)pos.x, (int)pos.y]; } else { return InventoryItem.NULL; } } return InventoryItem.NULL; } public Vector2 getItemPosition(Item item) { for (int y = 0; y < myItems.GetLength(1); y++) { for (int x = 0; x < myItems.GetLength(0); x++) { if (myItems[x, y] != null) { if (myItems[x, y].item.Equals(item)) { return new Vector2(x, y); } } } } return new Vector2(29, 11); } public Vector2 getNextAvailableSlot() { for (int y = 0; y < unlocked.GetLength(1); y++) { for (int x = 0; x < unlocked.GetLength(0); x++) { if (myItems[x, y].Equals(InventoryItem.NULL) && unlocked[x, y]) { return new Vector2(x, y); } } } return new Vector2(29, 11); } public Vector2 getNextSlot() { for (int y = 0; y < myItems.GetLength(1); y++) { for (int x = 0; x < myItems.GetLength(0); x++) { if (unlocked[x, y] == false) { return new Vector2(x, y); } } } return new Vector2(29, 11); } public static bool isValid(Vector2 validate) { return !validate.Equals(new Vector2(29, 11)); } public bool AddItem(InventoryItem newItem, Vector2 slot) { if (isValid(slot)) { if (newItem.status[1] != 0) //Item is stackable { if (isValid(getItemPosition(newItem.item)) && getItemByPosition(getItemPosition(newItem.item)).status[0] < 10) //Already exists, lets add to the stack. { int pos_x = (int)getItemPosition(newItem.item).x; int pos_y = (int)getItemPosition(newItem.item).y; myItems[pos_x, pos_y].status[0]++; //Increase the amount of the item return true; //Success on adding the item. } else //Item doesn't exist yet { myItems[(int)slot.x, (int)slot.y] = newItem; return true; } } else { //Item is not stackable, so add it to a new position myItems[(int)slot.x, (int)slot.y] = newItem; return true; } } return false; } public void OpenSlots(int amount) { Vector2 start = getNextSlot(); int done = 0; for (int y = (int)start.y; y < myItems.GetLength(1); y++) { for (int x = (int)start.x; x < myItems.GetLength(0); x++) { if (done < amount) { unlocked[x, y] = true; done++; } } } } public bool AddItem(InventoryItem item) { Vector2 position = getNextAvailableSlot(); if (isValid(position)) { if (AddItem(item, position)) { return true; } else { return false; } } return false; } public bool RemoveItem(InventoryItem item, int qtd) { Vector2 position = getItemPosition(item.item); if(isValid(position)) { InventoryItem i = myItems[(int)position.x, (int)position.y]; int itemQtd = i.status[0]; if(itemQtd - qtd < 1) { //Remover o item todo myItems[(int)position.x, (int)position.y] = InventoryItem.NULL; } else { i.status[0] -= qtd; } return true; } else { return false; } } public bool RemoveItem(List<InventoryItem> item) { for(int x = 0; x < item.Count; x++) { Vector2 position = getItemPosition(item[x].item); if (isValid(position)) { InventoryItem i = myItems[(int)position.x, (int)position.y]; int itemQtd = i.status[0]; if (itemQtd - item[x].status[0] < 1) { //Remover o item todo myItems[(int)position.x, (int)position.y] = InventoryItem.NULL; } else { i.status[0] -= item[x].status[0]; } } } return true; } public void RemoveFromHotbar(InventoryItem item) { Vector2 posToRemove = getItemPosition(item.item); for (int i = 0; i < myHotbar.Length; i++) { if (myHotbar[i].Equals(posToRemove)) { myHotbar[i] = new Vector2(29, 11); } } } } public class InventoryItem { public Item item; public List<int> status; public InventoryItem(Item i, List<int> s) { this.item = i; this.status = s; } public static List<int> DefaultStatus(bool stackable, int stackAmmount, int quantity) { //Status Configuration: //Quantity | Stackable | Ammo | Extra Ammo List<int> s = new List<int>(); if(stackable) { s.Add(quantity); //First is quantity s.Add(stackAmmount); //Second is stackable size } else { s.Add(quantity); //First Quantity s.Add(0); } s.Add(20); s.Add(40); return s; } public override string ToString() { if (item == null) return "Inv item with null item"; else return "InvItem | " + item.ToString(); } public static InventoryItem NULL = new InventoryItem(GameObject.Find("MPManager").GetComponent<ItemDatabase>().getItemByName("Fists"), null); }
  19. Hi guys, I've been using the free FPS Kit (http://armedunity.com/files/file/174-au-fps-kit-unity-5/) and i'm really confused about changing the hands, i just want to change the hands in the Kit and whenever i did everything works fine except the animation of hand (like reloading animation) can someone help me in changing the hands of this kit without having any animation issue ! Thanks
  20. Hey guys, I've been working on my new zombie game and i'm using Premium FPS kit 0.95, it's really a fabulous kit I've ever seen, with all features, for now i'm facing some really crazy problems in changing model of character and arms, please can someone help me with it I shall be very thankful to him :/ whenever i try to change it every time I get an error in return nothing changes, all working is done on GameObjects by the creator of that kit (ArmedUnity) and I've prefabs of models and arms I don't know how to change it, please guys help me, I'm really messed up
  21. Hello, I have got a problem. In my car game I want to add moving speedometers, but there is the problem. My camera sees that speedometer needle overlaps with the display behind it. But it is not so. - http://imgur.com/5a2BQU1 : Cameras view. - http://imgur.com/dCy3dAM : In editor (As you can see, there is a gap between them). - https://youtu.be/VtLBNEXa4LU?list=PL5f0H3dHKn9eTeaMcYLZZju_vgvFThHsR : My car game videos. Thanks for help.
  22. I need arms for my FPS, and i just cannot found some. Does someone know where I can found arms?
  23. 1.using UnityEngine; 2.using System.Collections; 3. 4.public class BirdControl : MonoBehaviour { 5. 6. 7.public Vector2 JumpForce = new Vector2 (0,500); 8. Use this for initialization 9.void Start () { 10. 11.} 12. 13. Update is called once per frame 14.void Update () { 15. 16. if (Input.GetKeyDown (KeyCode.Space)) { 17. GetComponent<Rigidbody2D>().AddForce (JumpForce); Unity error:Assets/Scripts/BirdControl.cs(20,1): error CS8025: Parsing error Can someone help me plz..
  24. Hi guys, fisrt of all, i have to say that i am learning C# so please dont be mean D: I was searching for a C# script to show an image while you are on a trigger. I have searched, but i only find JS tutorials. Please help
  25. public void makeProduct(string message) { makeButton.gameObject.SetActive (true); makePanel.SetActive (true); make2button.gameObject.SetActive(true); totalDev.gameObject.SetActive(true); totalDev.GetComponent<Text>().text = "Total Development Cost: $" + totalMake.ToString(); GetComponent<timeScript>().StopTimer(); } public void stopProduct() { print (gameName); if (pickedsystem == "Develop for:") { } else { makeButton.gameObject.SetActive(false); makePanel.SetActive(false); } GetComponent<timeScript>().StartTimer(); } I tried to make it in my gameDictionaries script that time would freeze, then having it resume when stopProduct is started. Then I had the following in my timeScript script(note, a lot of info here is useless as it is used for other parts): void Start() { InvokeRepeating("Timer", 0, 1); } public void Timer() { timeText.GetComponent<Text>().text = "W" + week.ToString() + "" + year.ToString() + " Day " + day.ToString(); playerCash.GetComponent<Text>().text = "$" + myCash.ToString(); #region YEAR //Check if month equals 13 (allows for 12th month to be counted) if (month == 13) { year++; month = 0; } #endregion #region MONTH //Check if week equals 5 (allows for 5th week to be counted) if (month == 5) { month++; week = 0; } #endregion #region WEEK //Check if day equals 8 (allows for 7th day to be counted) if (day == 8) { week++; day = 0; } #endregion #region DAY //Check if Time equals 5 (allows for 4 seconds) if (time == 1) { day++; time = 0; } else { time++; } #endregion if (week == 2 && month == 0 && year == 1980) { alert.PopUp("Welcome to iDeveloper! This is a pre-playable build that is not intended for consumer use"); } else if (week == 4 && month == 0 && year == 1980) { alert.PopUp("To create a game, go to Make Game"); } else if (week == 1 && month == 1 && year == 1981) { alert.PopUp("Create a game so you can earn money and grow your company!"); print("FES Coming in 4 years"); } print(week); print(month); print(year); } public void StartTimer() { InvokeRepeating("TimerFunction", 0, 1); Time.timeScale = 1f; } public void StopTimer() { CancelInvoke("Timer"); Time.timeScale = 0; } } The issue is, time isn't resuming when StartTimer is called. What could I do to get time to resume?