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



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
  • 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 43 results

  1. Hi guys, I duplicated the buggy in the fps kit, its an older version. The duplicate works fine, and I know the audio listener is traveling with the camera as I can hear the tires screeching it will just not emit the engine audio. Anyone know how to fix this?
  2. 1. Add this code on Ienumerator ApplyDamage in BulletScript.cs. if (hit.transform.tag != friendlyTag) { //Addthis if (hit.collider.gameObject.GetComponent<HealthScript>()) { hit.collider.gameObject.GetComponent<HealthScript>().PlayerDamage(System.Convert.ToInt32(damage)); } // hit.collider.SendMessage(damageMethodName, damage, SendMessageOptions.DontRequireReceiver); } 2. Add this code on IEnumerator Go() in ExplosionScript.cs if (hit.GetComponent<Collider>().gameObject.GetComponent<HealthScript>()) { hit.GetComponent<Collider>().gameObject.GetComponent<HealthScript>().PlayerDamage(System.Convert.ToInt32(damage)); } 3. Replace this in TargetScript.cs public void ApplyDamage(float h) { if (healthScriptHolder.GetComponent<HealthScript>()) { healthScriptHolder.GetComponent<HealthScript>().PlayerDamage(System.Convert.ToInt32(h)); } healthScriptHolder.SendMessage("Damage", h, SendMessageOptions.DontRequireReceiver); } 4. Change Player layer to default, Click this object only. 5. Change Damage Method Name to ApplyDamage, and Hit Effect Tag to Enemy on TSA bullet prefabs. Also on TSA Explosion Prefabs 6. Change AI prefab Tag to Enemy, which have collider component. And Apply Prefab. Noooww it's done. + You need to change TSA HealthScript.cs name, cuz it has same name as HealthScript.cs on FPS kit.
  3. KrypTik_Sweller

    Zombies game remodel

    If you remember my first zombies game made with the kit was basically crappy version of call of duty zombies, well now I have made it slightly more fun in my opinion. There are currently only 2 maps, the original Nazi base map which has a new room, new weapons and no longer has the broken mystery box. Some aspects of the map were changed for the purpose of flow and a few glitches were patched as well as new features like auto reload and a low ammo warning. I also added engrams that can drop random weapons from the zombies when you kill them basically like destiny. I also added a few weapons from destiny that you can get as well as a few other weapons from world war 2. Also added in a new perk in the new room. The bosses have a better and higher engram drop rate. The other map is a mixture of borderlands and some destiny aspects, mostly out in the open and only 1 perk in that map. the enemies are not Germans in this map they are borderlands style enemies. also has destiny weapons and the ww2 weapons and boss rounds. but in this map the only way to get new guns is through engrams. Just for fun not any other reason or commercial use at all. DOWNLOAD for more photos go to here and scroll down to previous project: http://clayschrome.wixsite.com/portfolio/my-work
  4. fpsarmedunity

    ammo pickup issue oma fpskit

    Hi to all.. i have a maybe simple question for you.. I noticed taht with oma fpskit 1.5 (c# version) if i approach to an ammo pickup i cannot pickup it if i havent a weapon pickuped yet (eg. sniper rifle) and ammo pickup prompt (press e key to puckup) will not shown .. but even if i have a weapon yet i can only pickup the ammo for the weapon i have.. i want to be able to pickup ammo even if i have not a weapon picked up yet and even if i dot have the correct weapon for ammo type... how can i manage to accomplish this?' many thanks in advance
  5. fpsarmedunity

    LockCursor & inventory System

    Hi i have i question.. I'm using fpskit as base of my project and i'm integrating an inventory system with pickup etc.. all works fine and only issue is that wheni close my inventory lockcursor remain in Cursor.lockState = CursorLockMode.None; and dont give me the full control of the player here a video of what happen here the lockcursor script i'm using using UnityEngine; using System.Collections; public class LockCursor : MonoBehaviour { // FPS KIT [www.armedunity.com] void Start() { Application.targetFrameRate = 120; #if UNITY_EDITOR Cursor.visible = true; Cursor.lockState = CursorLockMode.Locked; #else Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; #endif } void OnGUI() { if (Event.current.type == EventType.KeyDown) { /* if (Event.current.keyCode == KeyCode.P){ Screen.SetResolution (1920, 1080, true); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } */ if (Event.current.keyCode == KeyCode.I) { Cursor.visible = true; } } /* if (Cursor.lockState == CursorLockMode.None) { if (GUI.Button(new Rect(Screen.width - 120, 20, 100, 30), "Lock Cursor")) { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } } */ } } and there the inventory.cs script using UnityEngine; using System.Collections; using System.Collections.Generic; public class Inventory : MonoBehaviour { public int verticalSlots; public int horizontalSlots; public float slotSizeX; public float slotSizeY; [HideInInspector] public bool showInventory; [HideInInspector] public bool userHasOption = false; public Texture2D emptySlotTexture; public KeyCode inventoryInput; public GUISkin guiSkin; public List<Slot> inventory; private bool dragging = false; private GameObject equipedObject = null; private Vector2 windowPosition = Vector2.zero; private Vector2 windowSize = Vector2.zero; private Vector2 clickMousePosition = Vector2.zero; private Slot dragSlot = new Slot(); private Slot receiver = new Slot(); private PlayerInteraction playerInteraction = null; // Represents an Inventory Slot. public struct Slot { public int id; // Identifier used to find this Slot. public int itemID; // Returns the actual amount of Items inside this Slot. public int stacks { get { return slotObjects.Count; } } // Returns if we have more then one Item inside this Slot. public bool stackableSlot { get { return slotObjects.Count > 1; } } public List<GameObject> slotObjects; public Texture2D slotTexture; public Rect originalRect; public Rect currentRect; // Returns a bool indicating if this slots original Rect contains <cursorPosition>. public bool Contains (Vector2 cursorPosition) { return this.originalRect.Contains(cursorPosition); } // Returns a bool indicating if this slot is outside the GUI Windows Rect. public bool OutsideWindow (Vector2 windowPosition, Vector2 windowSize) { Rect windowRect = new Rect(windowPosition.x, windowPosition.y, windowSize.x, windowSize.y); return !windowRect.Contains(Event.current.mousePosition); } } private void OnValidate () { if (verticalSlots < 1) verticalSlots = 1; if (horizontalSlots < 1) horizontalSlots = 1; if (slotSizeY < 1) slotSizeY = 1; if (slotSizeX < 1) slotSizeX = 1; } private void Start () { // Find our PlayerInteraction MonoBehaviour on our Player Camera GameObject. //playerInteraction = transform.Find("MainCamera").GetComponent<PlayerInteraction>(); playerInteraction = GameObject.FindWithTag("MainCamera").transform.GetComponent<PlayerInteraction>(); // Inicialize our <inventory> List with a set <inventorySize> capacity. inventory = new List<Slot>(horizontalSlots * verticalSlots); // Calculate the <windowSize> based on the <slotSize> and the amount of slots. windowSize = new Vector2(horizontalSlots * slotSizeX, verticalSlots * slotSizeY); // Calculate the <windowPosition> based on <windowSize>. windowPosition = new Vector2((Screen.width - windowSize.x) / 2, (Screen.height - windowSize.y) / 2); // Our current (X,Y) positions inside our GUI Window. float currentX = windowPosition.x; float currentY = windowPosition.y; // Add an empty slot for each available slot in the <inventory>. for (int i = 0; i < inventory.Capacity; i++) { Slot emptySlot = new Slot(); emptySlot.id = i; emptySlot.itemID = 0; emptySlot.slotObjects = new List<GameObject>(); emptySlot.slotTexture = emptySlotTexture; emptySlot.originalRect = new Rect(currentX, currentY, slotSizeX, slotSizeY); emptySlot.currentRect = emptySlot.originalRect; // Move horizontally by <slotSize>. currentX += slotSizeX; // Check if we can fit another Slot horizontally. if (currentX + slotSizeX > windowPosition.x + windowSize.x) { // If we cannot fit another slot horizontally then move vertically and // reset our horizontal position. currentX = windowPosition.x; currentY += slotSizeY; } inventory.Add(emptySlot); } } private void Update () { // Show or hide this inventory. if (Input.GetKeyDown(inventoryInput)) { showInventory = !showInventory; Cursor.visible = showInventory; //Cursor.visible = true; Cursor.lockState = CursorLockMode.None; GetComponent<MouseLook>().enabled = !showInventory; //tranform.Find("Camera").GetComponent<MouseRotation>().enabled = !showInventory; //GameObject.FindWithTag("MouseLook").GetComponent<MouseLook>().enabled = !showInventory; GameObject.Find("MouseLook").GetComponent<MouseLook>().enabled = !showInventory; } } private void OnGUI () { GUI.skin = guiSkin; if (showInventory) { // The Inventory's Header. GUI.Box(new Rect(windowPosition.x, windowPosition.y - 25, windowSize.x, 30), "Inventory"); // The Inventory's Window. GUI.Box(new Rect(windowPosition.x, windowPosition.y, windowSize.x, windowSize.y), ""); for (int i = 0; i < inventory.Count; i++) { if (inventory[i].stackableSlot) { // If this slot is stackable then draw a label counting the amount of // stacks and disable the ability to equip this stackable item. string stackLabel = string.Format("<b><size=20>{0}</size></b>", inventory[i].stacks); // Stackable items are not equipable. GUI.Button(inventory[i].currentRect, inventory[i].slotTexture); // Only show the stack amount label is we have more then 1 item stacked. if (inventory[i].stacks > 0) GUI.Label(inventory[i].currentRect, stackLabel); } else { // If we click this Slot Button then equip the GameObject it holds. if (GUI.Button(inventory[i].currentRect, inventory[i].slotTexture) && !userHasOption) { Item slotItem = inventory[i].slotObjects[0].GetComponent<Item>(); if (inventory[i].slotObjects.Count > 0 && slotItem.usable) { GameObject slotObject = inventory[i].slotObjects[0]; slotObject.SendMessage("InventoryUse", SendMessageOptions.DontRequireReceiver); Destroy(inventory[i].slotObjects[inventory[i].slotObjects.Count - 1]); inventory[i].slotObjects.RemoveAt(inventory[i].slotObjects.Count - 1); if (inventory[i].slotObjects.Count < 1) inventory[i] = ResetSlot(inventory[i]); } } } // If the mouse is inside this Slot then watch for dragging. if (inventory[i].Contains(Event.current.mousePosition) && !dragging) { // If we click with the left mouse button set its click screen position; if (Input.GetMouseButtonDown(0)) { clickMousePosition = Event.current.mousePosition; } // If we clicked then moved our mouse that means we are dragging the slot. if (Input.GetMouseButton(0) && Event.current.mousePosition != clickMousePosition) { // Prevent the Player from dragging empty slots. if (inventory[i].slotObjects.Count > 0) { dragSlot = inventory[i]; dragging = true; } } } if (dragging) { if (Input.GetMouseButtonUp(0)) { // If we released our left mouse button and the Slots Rect is // outside the Window, then drop the item it contained. if (dragSlot.OutsideWindow(windowPosition, windowSize)) { if (dragSlot.slotObjects.Count > 0) { Item item = null; if (dragSlot.stackableSlot) { // If we are a stackable Slot then we drop 1 of the stacked items. if (dragSlot.slotObjects.Count == 1) { // If we only have 1 GameObject left then drop it and restore this // slot to a normal empty slot. item = dragSlot.slotObjects[0].GetComponent<Item>(); dragSlot = ResetSlot(dragSlot); } else { int lastItemIndex = dragSlot.slotObjects.Count - 1; item = dragSlot.slotObjects[lastItemIndex].GetComponent<Item>(); dragSlot.slotObjects.RemoveAt(lastItemIndex); } } else { // If the Slot we dragged out of the Window is not stackable // then just drop the item it contained. item = dragSlot.slotObjects[0].GetComponent<Item>(); dragSlot = ResetSlot(dragSlot); if (equipedObject != null) { equipedObject.SetActive(false); equipedObject = null; } } item.DropItem(); // Since we are modifying this Slot inside the main foreach loop // calling UpdateSlotData() would be extremelly slow due to a // loop inside another loop. inventory[inventory[i].id] = inventory[i]; } } else { // If we dropped the Item inside the Window, check what Slot we dropped // it upon. for (int y = 0; y < inventory.Count; y++) { // If this instance is the <dragSlot> itself then skip it. if (inventory[y].id == dragSlot.id) continue; // If we found a Slot that contains the mouse then exchange // Slot information from the <dragSlot> to the <receiverSlot> // and the <receiverSlot> to the <dragSlot>. if (inventory[y].Contains(Event.current.mousePosition)) { receiver = inventory[y]; userHasOption = true; break; } } } // If we got our left mouse button up return the <dragSlot> // to its original position. dragSlot.currentRect = dragSlot.originalRect; // Update the <dragSlot>'s data. UpdateSlotData(dragSlot); // And since we released the left mouse button we are no longer dragging. dragging = false; break; } // If we are dragging then set the <dragSlot>'s position to be the current // mouse cursor's position (Compensating for the <slotSize> offset). dragSlot.currentRect.x = Event.current.mousePosition.x - 35; dragSlot.currentRect.y = Event.current.mousePosition.y - 35; // If the current slot being iterated is the <dragSlot> then update its info. if (inventory[i].id == dragSlot.id) inventory[inventory.IndexOf(inventory[i])] = dragSlot; } } if (userHasOption) { // Prompt the Player if he wants to create whatever the combination // of both items can create or just exchange Slots. if (receiver.slotObjects.Count == 0) { if (dragSlot.stackableSlot && dragSlot.stacks > 1) { Rect button1Rect = new Rect(Screen.width - windowPosition.x, Screen.height - windowPosition.y - 80, 150, 40); Rect button2Rect = new Rect(Screen.width - windowPosition.x, Screen.height - windowPosition.y - 40, 150, 40); if (GUI.Button(button1Rect, "Move Stack")) { receiver.itemID = dragSlot.itemID; receiver.slotObjects = dragSlot.slotObjects; receiver.slotTexture = dragSlot.slotTexture; dragSlot.itemID = 0; dragSlot.slotObjects = new List<GameObject>(); dragSlot.slotTexture = emptySlotTexture; UpdateSlotData(receiver); UpdateSlotData(dragSlot); userHasOption = false; } if (GUI.Button(button2Rect, "Seperate Stack")) { receiver.itemID = dragSlot.itemID; receiver.slotObjects.Add(dragSlot.slotObjects[dragSlot.slotObjects.Count - 1]); receiver.slotTexture = dragSlot.slotTexture; dragSlot.slotObjects.RemoveAt(dragSlot.slotObjects.Count - 1); UpdateSlotData(receiver); UpdateSlotData(dragSlot); userHasOption = false; } } else { ExchangeSlots(dragSlot, receiver); userHasOption = false; } } else { Rect button1Rect = new Rect(Screen.width - windowPosition.x, Screen.height - windowPosition.y - 120, 150, 40); Rect button2Rect = new Rect(Screen.width - windowPosition.x, Screen.height - windowPosition.y - 80, 150, 40); Rect button3Rect = new Rect(Screen.width - windowPosition.x, Screen.height - windowPosition.y - 40, 150, 40); // GUI Button for combining 2 Slot items. CraftingCombinations crafting = this.GetComponent<CraftingCombinations>(); string craftableItem = ""; int newItemID = 0; foreach (CraftingCombinations.ItemCombination combination in crafting.itemCombinations) { int combinationSum = (combination.itemID1 * 10) + combination.itemID2; int inventorySum = (dragSlot.itemID * 10) + receiver.itemID; if (combinationSum == inventorySum) { craftableItem = combination.name; newItemID = combinationSum; } } if (newItemID != 0) { // GUI Button for crafting items. if (GUI.Button(button3Rect, "Craft " + craftableItem)) { GameObject craftedObject = Resources.Load<GameObject>(craftableItem); GameObject craftedInstance = (GameObject)Instantiate(craftedObject); craftedInstance.name = craftableItem; CraftItem(craftedInstance, newItemID); } } // GUI Button for swaping Slots. if (GUI.Button(button2Rect, "Swap Items")) { ExchangeSlots(dragSlot, receiver); userHasOption = false; } // GUI Button for stacking Slots. if (receiver.itemID == dragSlot.itemID) { if (GUI.Button(button1Rect, "Stack Items")) { receiver.slotObjects.Add(dragSlot.slotObjects[dragSlot.slotObjects.Count - 1]); dragSlot.slotObjects.RemoveAt(dragSlot.slotObjects.Count - 1); if (dragSlot.slotObjects.Count < 1) { for (int i = 0; i < inventory.Count; i++) { if (inventory[i].id == dragSlot.id) { inventory[i] = ResetSlot(inventory[i]); break; } } } userHasOption = false; } } } } } } public void CraftItem (GameObject craftedObject, int newItemID) { Item craftedItem = craftedObject.GetComponent<Item>(); // Remove the item from the <dragSlot>. if (dragSlot.slotObjects.Count > 0) { Destroy(dragSlot.slotObjects[dragSlot.slotObjects.Count - 1]); if (dragSlot.stacks > 1) { dragSlot.slotObjects.RemoveAt(dragSlot.slotObjects.Count - 1); } else { dragSlot = ResetSlot(dragSlot); } } // Remove the item from the <receiver> Slot. if (receiver.slotObjects.Count > 0) { Destroy(receiver.slotObjects[receiver.slotObjects.Count - 1]); if (receiver.stacks > 1) { receiver.slotObjects.RemoveAt(receiver.slotObjects.Count - 1); } else { receiver = ResetSlot(receiver); } craftedItem.PickupItem(this.transform); if (InventoryHasSpace()) { Slot slot = new Slot(); for (int i = 0; i < inventory.Count; i++) { slot = inventory[i]; if (slot.itemID == 0) { slot.itemID = newItemID; slot.slotTexture = craftedItem.slotIcon; slot.slotObjects.Add(craftedObject); break; } } UpdateSlotData(slot); } else { craftedItem.DropItem(); } } UpdateSlotData(receiver); UpdateSlotData(dragSlot); userHasOption = false; } public bool InventoryHasSpace() { foreach (Slot slot in inventory) { if (slot.slotObjects.Count == 0) return true; } return false; } public void AddItem (Item item) { if (!InventoryHasSpace()) { Debug.Log("No available slots in inventory for " + item.name + " to be added."); return; } Slot editSlot = new Slot(); // If this item is stackable then find a Slot with its similar // GameObject type and stack it, if there is none, just add it. if (item.maxStackAmount > 1) { // Search for any stackable Slots with the same GameObject type as // the one we want to add. List<Slot> stackableSlots = FindSlot(item.itemID); if (stackableSlots.Count > 0) { foreach (Slot stackableSlot in stackableSlots) { if (stackableSlot.stacks < item.maxStackAmount) { // If we found a stackable Slot with the same GameObject type as // the one we want to add, then add another stack to that slot. // If this is the Slots first stack set it to stackable. stackableSlot.slotObjects.Add(playerInteraction.currentObject); editSlot = stackableSlot; break; } } if (editSlot.itemID == 0) editSlot = AddToEmptySlot(item); } else { // If we do not already contain this GameObject type then just add it. editSlot = AddToEmptySlot(item); } } else { // If this item is not stackable then just add it to an empty Slot. editSlot = AddToEmptySlot(item); } // Pickup the item we were interacting with. item.PickupItem(this.transform); // Update the actual inventory Slot. UpdateSlotData(editSlot); } private Slot ResetSlot (Slot slot) { slot.itemID = 0; slot.slotObjects = new List<GameObject>(); slot.slotTexture = emptySlotTexture; return slot; } // Exchanges information between the <sender> and <receiver> Slots. private void ExchangeSlots(Slot sender, Slot receiver) { // Check if the <sender> has any information to exchange, otherwise // there is no reason to exchange Nothing for Nothing. if (sender.slotObjects.Count > 0) { Slot oldSender = sender; // Change the <dragSlot>'s information to the ones the <receiver> Slot had. sender.itemID = receiver.itemID; sender.slotObjects = receiver.slotObjects; sender.slotTexture = receiver.slotTexture; // Change the <receiver>'s information to the ones the <dragSlot> had. receiver.itemID = oldSender.itemID; receiver.slotObjects = oldSender.slotObjects; receiver.slotTexture = oldSender.slotTexture; UpdateSlotData(sender); UpdateSlotData(receiver); } } // Finds the next available empty Slot. private Slot FindSlot() { foreach (Slot slot in inventory) { if (slot.slotObjects.Count == 0) return slot; } return new Slot(); } // Finds the slot that contains a GameObject with the same // type as the <objectName>. private List<Slot> FindSlot(int objectID) { List<Slot> foundSlots = new List<Slot>(); foreach (Slot slot in inventory) { if (slot.itemID == objectID) foundSlots.Add(slot); } return foundSlots; } // Finds the <target> Slot inside the Inventory by using its id. private void UpdateSlotData (Slot target) { for (int i = 0; i < inventory.Count; i++) { if (inventory[i].id == target.id) inventory[i] = target; } } private Slot AddToEmptySlot (Item item) { Slot editSlot = FindSlot(); if (editSlot.slotObjects.Count == 0) { // Add the GameObject we were interacting with to the slot. editSlot.slotObjects.Add(playerInteraction.currentObject); editSlot.slotTexture = item.slotIcon; editSlot.itemID = item.itemID; } return editSlot; } }
  6. fpsarmedunity

    fps kit1.5 zombie Ai error

    Hi ,as i wrote in a prevoius topic I'm learning and experimenting with great oma fps kit 1.5 c# version now i'm trying to add a form of simple AI and I'm trying to add classic zombie ai form fpskit 1.3.5 i copied all (scripts asset nanimations ect_) and all works fine except fot the fact that when my player die and there are more zombies on the scene my test game got an error MissingReferenceException: The object of type 'Transform' 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. UnityEngine.Transform.get_position () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineTransformBindings.gen.cs:26) AI.Update () (at Assets/MyEnemies/Zombie/AI.cs:47) realted to my zombie AI.cs due to the fact that zombie try to check the distance to the player but the "player" in not in scene this is the script using UnityEngine; using System.Collections; public class AI : MonoBehaviour { public 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 AudioClip attack; private bool chasing = false; private float attackTime; public bool checkRay = false; public string idleAnim = "idle"; public string walkAnim = "walk"; public string attackAnim = "attack"; public int dontComeCloserRange = 4; private Transform myTransform; //current transform data of this enemy void Awake() { myTransform = transform; //cache transform data for easy access/preformance anim.GetComponent<Animation>().wrapMode = WrapMode.Loop; anim.GetComponent<Animation>()[attackAnim].wrapMode = WrapMode.Once; anim.GetComponent<Animation>()[attackAnim].layer = 2; anim.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].speed = .4f; anim.GetComponent<Animation>().CrossFade(idleAnim); } else { moveSpeed = Random.Range(4, 6); anim.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, transform.eulerAngles.y, 0); // 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 = 2.0f; anim.GetComponent<Animation>().CrossFade(attackAnim); target.SendMessage("PlayerDamage", maximumHitPoints); attackTime = Time.time + attackRepeatTime; GetComponent<AudioSource>().PlayOneShot(attack, 1.0f / GetComponent<AudioSource>().volume); } } else { // not currently chasing. anim.GetComponent<Animation>()[idleAnim].speed = .4f; anim.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); } } can please someone try to help me to fix this error?' many thanks in advance
  7. damh0503

    Remove the function that goes over

    Hi, I wanna remove the function that goes over, what code should I remove/change on FPSController.cs? https://youtu.be/CGDkDKmpcJA
  8. using UnityEngine; using System.Collections; public class FPSController : MonoBehaviour { // FPS Kit [www.armedunity.com] public int proneSpeed = 1; public int crouchSpeed = 4; public int walkSpeed = 6; public int runSpeed = 10; public float jumpSpeed = 8.0f; private float gravity = 24; public float baseGravity = 24; public float proneGravity = 15; private float normalFDTreshold = 8; private float proneFDTreshold = 4; private float fallingDamageThreshold; public float fallDamageMultiplier = 5.0f; private float slideSpeed = 8.0f; private float antiBumpFactor = .75f; private float antiBunnyHopFactor = 1; public bool airControl = false; [SerializeField] private AudioClip[] m_LadderSounds; // Ladder Script [SerializeField] public float climbRate = 0.5f; //Ladder Script private float playTime = 0.0f; //ladder [HideInInspector] public bool run; [HideInInspector] public bool canRun = true; public Transform cameraGO; [HideInInspector] Vector3 moveDirection= Vector3.zero; [HideInInspector] public bool grounded = false; private Transform myTransform; [HideInInspector] public float speed; private RaycastHit hit; private float fallDistance; private bool falling = false; public float slideLimit = 45.0f; public float rayDistance; private Vector3 contactPoint; private int jumpTimer; private float normalHeight = 0.9f; private float crouchHeight = 0.2f; private float proneHeight = -0.4f; [HideInInspector] public int state = 0; // 0 = standing // 1 = crouching // 2 = prone private float adjustAnimSpeed = 7.0f; //Ladders [HideInInspector] public bool onLadder = false; public UseLadder useladder; private Vector3 currentPosition; private Vector3 lastPosition; private float highestPoint; public HealthScript hs; public WeaponManager wm; public FootSteps footsteps; private float crouchProneSpeed = 3; private float distanceToObstacle; private bool sliding = false; [HideInInspector] public float velMagnitude; public CharacterController controller; public Animation walkRunAnim; public Animation cameraAnimations; private string runAnimation = "CameraRun"; private string idleAnimation = "IdleAnimation"; // WATER public bool underWater = false; public bool swimming = false; private float swimAccel; private float underWaterTimer = 0.0f; public UnityStandardAssets.ImageEffects.BlurOptimized blur; private float waterLevel; private float underwaterLevel; public AudioSource aSource; public AudioSource waterSource; public AudioClip enterPool; public AudioClip enterPoolSplash; public AudioClip bodyHitSound; public AudioClip inhale; public Transform fallEffect; public Transform fallEffectWep; public GameObject waterSplash; public ParticleEmitter waterFoam; private ParticleEmitter emiter; void Start() { myTransform = transform; rayDistance = controller.height / 2 + 1.1f; slideLimit = controller.slopeLimit - .2f; walkRunAnim.wrapMode = WrapMode.Loop; walkRunAnim.Stop(); cameraAnimations[runAnimation].speed = 0.8f; } void Update() { velMagnitude = controller.velocity.magnitude; float inputX = Input.GetAxis("Horizontal"); float inputY = Input.GetAxis("Vertical"); float inputModifyFactor = (inputX != 0.0f && inputY != 0.0f) ? .7071f : 1.0f; if (onLadder) { useladder.LadderUpdate(); highestPoint = myTransform.position.y; run = false; fallDistance = 0.0f; grounded = false; walkRunAnim.CrossFade(idleAnimation); cameraAnimations.CrossFade(idleAnimation); return; } if (swimming) { highestPoint = myTransform.position.y; run = false; fallDistance = 0.0f; grounded = false; state = 2; walkRunAnim.CrossFade(idleAnimation); cameraAnimations.CrossFade(idleAnimation); } if (grounded) { gravity = baseGravity; if (Physics.Raycast(myTransform.position, -Vector3.up, out hit, rayDistance)) { float hitangle = Vector3.Angle(hit.normal, Vector3.up); if (hitangle > slideLimit) { sliding = true; } else { sliding = false; } } if (canRun && state == 0) { if (Input.GetButton("Run") && Input.GetKey("w") && !Input.GetButton("Fire2")) { run = true; } else { run = false; } } if (falling) { if (state == 2) fallingDamageThreshold = proneFDTreshold; else fallingDamageThreshold = normalFDTreshold; falling = false; fallDistance = highestPoint - currentPosition.y; if (fallDistance > fallingDamageThreshold) { ApplyFallingDamage(fallDistance); } if (fallDistance < fallingDamageThreshold && fallDistance > 0.1f) { if (state < 2) footsteps.JumpLand(); else if (bodyHitSound) aSource.PlayOneShot(bodyHitSound, 0.5f); StartCoroutine(FallCamera(new Vector3(7, Random.Range(-1.0f, 1.0f), 0), new Vector3(3, Random.Range(-0.5f, 0.5f), 0), 0.15f)); } } if (sliding) { Vector3 hitNormal = hit.normal; moveDirection = new Vector3(hitNormal.x, -hitNormal.y, hitNormal.z); Vector3.OrthoNormalize( ref hitNormal, ref moveDirection); moveDirection *= slideSpeed; } else { if (state == 0) { if (run) speed = runSpeed; else if (Input.GetButton("Fire2")) { speed = crouchSpeed; } else { speed = walkSpeed; } } else if (state == 1) { speed = crouchSpeed; run = false; } else if (state == 2) { speed = proneSpeed; run = false; } if (Cursor.lockState == CursorLockMode.Locked) moveDirection = new Vector3(inputX * inputModifyFactor, -antiBumpFactor, inputY * inputModifyFactor); else moveDirection = new Vector3(0, -antiBumpFactor, 0); moveDirection = myTransform.TransformDirection(moveDirection); moveDirection *= speed; if (!Input.GetButton("Jump")) { jumpTimer++; } else if (jumpTimer >= antiBunnyHopFactor) { jumpTimer = 0; if (state == 0) { moveDirection.y = jumpSpeed; } if (state > 0) { CheckDistance(); if (distanceToObstacle > 1.6f) { state = 0; } } } } } else { currentPosition = myTransform.position; if (currentPosition.y > lastPosition.y) { highestPoint = myTransform.position.y; falling = true; } if (!falling) { highestPoint = myTransform.position.y; falling = true; } if (airControl) { moveDirection.x = inputX * speed; moveDirection.z = inputY * speed; moveDirection = myTransform.TransformDirection(moveDirection); } if (swimming) { if (swimAccel > 0.0f) swimAccel -= Time.deltaTime * 4.0f; if (Input.GetButton("Run")) { Vector3 swimDir = cameraGO.transform.TransformDirection(Vector3.forward); if (transform.position.y >= waterLevel && swimDir.y > 0.0f) swimDir.y = 0.0f; if (swimAccel <= 1.0f) { StartCoroutine(FallCamera( new Vector3(7, Random.Range(-5.0f, 5.0f), 0), new Vector3(4, 0, 0), 0.15f)); swimAccel = 6.0f; } if (swimAccel > 1.0f) moveDirection = swimDir * swimAccel; } else { moveDirection.x = inputX * 2.0f; moveDirection.z = inputY * 2.0f; moveDirection = myTransform.TransformDirection(moveDirection); } if (underWater) { underWaterTimer += Time.deltaTime; if (underWaterTimer > 15.0f) { StartCoroutine(FallCamera(new Vector3(Random.Range(-2.0f, 5.0f), Random.Range(-7.0f, 7.0f), 0),new Vector3(4, Random.Range(-2.0f, 2.0f), 0), 0.1f)); hs.PlayerDamage(10); underWaterTimer = 12.0f; } } } } if (grounded) { if (velMagnitude > crouchSpeed && !run) { walkRunAnim["Walk"].speed = velMagnitude / adjustAnimSpeed; walkRunAnim.CrossFade("Walk"); } else { walkRunAnim.CrossFade(idleAnimation); } if (run && velMagnitude > walkSpeed) { walkRunAnim.CrossFade("Run"); cameraAnimations.CrossFade(runAnimation); } else { cameraAnimations.CrossFade(idleAnimation); } } else { walkRunAnim.CrossFade(idleAnimation); cameraAnimations.CrossFade(idleAnimation); run = false; } if (Input.GetButtonDown("Crouch")) { CheckDistance(); if (state == 0) { state = 1; } else if (state == 1) { if (distanceToObstacle > 1.6f) { state = 0; } } else if (state == 2) { if (distanceToObstacle > 1) { state = 1; } } } if (Input.GetButtonDown("Prone")) { CheckDistance(); if (state == 0 || state == 1) { state = 2; } else if (state == 2) { if (distanceToObstacle > 1.6f) { state = 0; } } if (!grounded) gravity = proneGravity; } if (state == 0) { //Stand Position controller.height = 2.0f; controller.center = new Vector3(0, 0, 0); if (cameraGO.localPosition.y > normalHeight) { cameraGO.localPosition = new Vector3(cameraGO.localPosition.x, normalHeight, cameraGO.localPosition.z); } else if (cameraGO.localPosition.y < normalHeight) { cameraGO.localPosition = new Vector3(cameraGO.localPosition.x,cameraGO.localPosition.y + Time.deltaTime * crouchProneSpeed, cameraGO.localPosition.z) ; } } else if (state == 1) { //Crouch Position controller.height = 1.4f; controller.center = new Vector3(0, -0.3f, 0); if (cameraGO.localPosition.y != crouchHeight) { if (cameraGO.localPosition.y > crouchHeight) { cameraGO.localPosition = new Vector3(cameraGO.localPosition.x,cameraGO.localPosition.y - Time.deltaTime * crouchProneSpeed, cameraGO.localPosition.z) ; } if (cameraGO.localPosition.y < crouchHeight) { cameraGO.localPosition = new Vector3(cameraGO.localPosition.x, cameraGO.localPosition.y + Time.deltaTime * crouchProneSpeed, cameraGO.localPosition.z) ; } } } else if (state == 2) { //Prone Position controller.height = 0.6f; controller.center = new Vector3(0, -0.7f, 0); if (cameraGO.localPosition.y < proneHeight) { cameraGO.localPosition = new Vector3(cameraGO.localPosition.x,proneHeight,cameraGO.localPosition.z); } else if (cameraGO.localPosition.y > proneHeight) { cameraGO.localPosition = new Vector3(cameraGO.localPosition.x, cameraGO.localPosition.y - Time.deltaTime * crouchProneSpeed, cameraGO.localPosition.z); } } if (!swimming) moveDirection.y -= gravity * Time.deltaTime; grounded = (controller.Move(moveDirection * Time.deltaTime) & CollisionFlags.Below) != 0; } void CheckDistance() { Vector3 pos = myTransform.position + controller.center - new Vector3(0, controller.height / 2, 0); RaycastHit hit; if (Physics.SphereCast(pos, controller.radius, myTransform.up, out hit, 10)) { distanceToObstacle = hit.distance; Debug.DrawLine(pos, hit.point, Color.red, 2.0f); } else { distanceToObstacle = 3; } } void LateUpdate() { lastPosition = currentPosition; if (swimming) { moveDirection.y = 0.5f + (underwaterLevel - transform.position.y); //if(transform.position.y > waterLevel && !grounded) // transform.position.y = waterLevel; if (emiter) emiter.emit = !underWater; if (transform.position.y > underwaterLevel) { if (underWaterTimer > 5.0f) { GetComponent<AudioSource>().clip = inhale; GetComponent<AudioSource>().Play(); } underWater = false; underWaterTimer = 0.0f; blur.enabled = false; aSource.Stop(); } if (transform.position.y > waterLevel && grounded) { swimming = false; if (emiter) { emiter.emit = false; emiter.transform.parent = null; } wm.ExitWater(); state = 0; } } } IEnumerator FallCamera(Vector3 d, Vector3 dw, float ta) { Quaternion s = fallEffect.localRotation; Quaternion sw = fallEffectWep.localRotation; Quaternion e = fallEffect.localRotation * Quaternion.Euler(d); // Quaternion ew = fallEffectWep.localRotation * Quaternion.Euler(dw); float r = 1.0f / ta; float t = 0.0f; while (t < 1.0f) { t += Time.deltaTime * r; fallEffect.localRotation = Quaternion.Slerp(s, e, t); fallEffectWep.localRotation = Quaternion.Slerp(sw, e, t); yield return null; } } void PlayerInWater(float s) { waterLevel = s + 0.9f; underwaterLevel = s + 0.4f; blur.enabled = true; if (GetComponent<AudioSource>().isPlaying) GetComponent<AudioSource>().Stop(); if (!aSource.isPlaying) aSource.Play(); if (!swimming) { wm.EnterWater(); if (grounded) { Instantiate(waterSplash, transform.position + new Vector3(0, -0.5f, 0), transform.rotation); waterSource.PlayOneShot(enterPool, 1.0f); } else { Instantiate(waterSplash, transform.position + new Vector3(0, 0.5f, 0.2f), transform.rotation); Instantiate(waterSplash, transform.position, transform.rotation); Instantiate(waterSplash, transform.position + new Vector3(0, -0.5f, 0.5f), transform.rotation); waterSource.PlayOneShot(enterPoolSplash, 1.0f); } emiter = Instantiate(waterFoam, transform.position + new Vector3(0, -0.7f, 0), transform.rotation) as ParticleEmitter; emiter.transform.parent = this.transform; } underWater = true; swimming = true; } void ApplyFallingDamage(float fallDistance) { hs.PlayerFallDamage(fallDistance * fallDamageMultiplier); if (state < 2) StartCoroutine(footsteps.JumpLand()); StartCoroutine( FallCamera(new Vector3(12, Random.Range(-2.0f, 2.0f), 0), new Vector3(4, Random.Range(-1.0f, 1.0f), 0), 0.1f)); } public void OnLadder() { onLadder = true; moveDirection = Vector3.zero; grounded = false; //int r = Random.Range(0, m_LadderSounds.Length); //aSource.clip = m_LadderSounds[r]; //aSource.PlayOneShot(aSource.clip); //playTime = Time.time + climbRate; if /*(Input.GetAxis("Vertical") == 1 &&*/(Input.GetKey(KeyCode.W) && !(aSource.isPlaying) && Time.time >= playTime ) { PlayLadderSound(); } } //Ladder Footsteps void PlayLadderSound() { if (onLadder = (true)) { int r = Random.Range(0, m_LadderSounds.Length); aSource.clip = m_LadderSounds[r]; aSource.PlayOneShot(aSource.clip); playTime = Time.time + climbRate; } } public void OffLadder(Vector3 ladderMovement) { onLadder = false; Vector3 dir = gameObject.transform.forward; if (Input.GetAxis("Vertical") > 0) { moveDirection = dir.normalized * 5.0f; } } } Hi I'm trying to add ladder sounds when clim ladder into the FPSController.cs from FPSKIT but when i trigger the ladder my script play only one first sound and when i climb no other sounds are reproduced above there is the code i have can please someone give me some hints how to resolve??
  9. Hello, I'm using the FPSKit_v1.3.5. The project is being built for android, so I am replacing the models with low poly ones. I have all the "low poly gun models" lined across a table, they have colliders and weapon index and I can pick them up. Then, I have clones of these "low poly gun models" with only a "Weapon Script" & "Weapon Index" and these are attached to the Weapon Camera (for when wielded) So, all is perfect, until i drop a weapon. When the "low poly gun models" get dropped they are replaced with the original "high poly models". Although they do still have an index and everything works perfectly, except i want these "dropped models" to be the "low poly models" I tried, replacing the "World Models (Rigidbody)" with the low poly models (in the WeaponManager). But, then they disappear after dropping them. Not sure what I'm doing wrong? Any help would be greatly appreciated! Please & Thank you!
  10. Hello! I am a noob, with no formal education, so, I really appreciate these free FPSKits! They're great for learning, awesome for noobs like myself. I'm using the FPSKit v1.3.5 written in Unity Javascript. The issue I'm having is with the GUI elements. (ex. health, ammo, score, etc.) I simply want to move them to the top center of the screen. But, the only GUI experience I have is with the new Unity GUI Canvas etc. I think I have to change the "Rect Width/Height values". But, I'm not sure where?? Any help is greatly appreciated. Thanks.
  11. So for the past month I've been Trying to add multiplayer to OMA's FPSKIT 1.5, What i'm trying to do is get the players control independently of each other, I have tried and followed many tutorials and so homemade scripts but none have worked, so i thought i would come on here and see if anyone has any knowledge with networking and free up the characters.
  12. shovikishere

    Melee weapon in FPS Kit

    I have downloaded FPS Kit and was trying to implement it in my scene. But I cant' figure out how can I add a melee weapon such as a knife or something like that. And also how can I add hand grenades.
  13. xIconikkx

    Unity 5 | FPSKit | UI Problem

    Hi, I was hoping someone could help! I'm using the FPSKit, the one that has been updated to Unity 5. I'm trying to add Modern UI in my scene, as soon as I add the canvas, I cant seem to pick up the weapons. But as soon as I remove the canvas I can pick up weapons?! All the UI works etc, can use buttons what not, just cant pick up weapons Thanks for any answers!
  14. KillerScript

    Help| Flashlight sync' over network

    Hey, I'm using FPS Kit And I want to know how to sync my playr's plash lights That when I will turn my flashlight on, other players will be able to see the light, AND even see the flare that comes from the flashlight. How can I do that? This is something that I have: var light : Light; private var lightOn : boolean = false; function Update () { if(networkView.isMine){ if(Input.GetKeyDown(KeyCode.F)){ if(!lightOn){ networkView.RPC("TurnLightOn", RPCMode.All, true); //Turn on } else{ networkView.RPC("TurnLightOn", RPCMode.All, true); //Turn off } lightOn = !lightOn; } } } @RPC function TurnLightOn (on : boolean) { lightOn = on; if(on){ light.intensity = 1; } else{ light.intensity = 0; } } And I'm getting this error: Assets/Resources/OldScripts/Misc/FlashLight.js(25,9): BCE0004: Ambiguous reference 'light': FlashLight.light, UnityEngine.Component.light.
  15. So i modified some of the scripts in FPS Kit 1.3.5 To suit my needs for a survival horror game and converted the language(not codes) to english I Thought I would contribute to the community by sharing them. (for the new FPS KIT users) /** * Script written by OMA [www.armedunity.com] * Edited for survival horror by Ryan199Gamer **/ @script ExecuteInEditMode() var time : float = 0.0; var hitCrosshairTexture : Texture; private var alphaHit : float; var hitSound : AudioClip; var mySkin : GUISkin; function Update () { if (time > 0){ time -= Time.deltaTime; } alphaHit = time; } function DrawCrosshair(){ yield WaitForSeconds(0.1); time = 1.0; audio.PlayOneShot(hitSound, .5); } function PlayAudioClip (clip : AudioClip, position : Vector3, volume : float) { var go = new GameObject ("TiroAudio"); go.transform.position = position; var source : AudioSource = go.AddComponent (AudioSource); source.clip = clip; source.volume = volume; source.pitch = Random.Range(0.95,1.05); source.Play (); Destroy (go, clip.length); return source; } function OnGUI(){ if(!Screen.lockCursor) return; GUI.skin = mySkin; var style1 = mySkin.customStyles[0]; GUI.color = Color(1.0, 1.0, 1.0, alphaHit); GUI.DrawTexture (Rect ((Screen.width - hitCrosshairTexture.width)/2, (Screen.height - hitCrosshairTexture.height)/2, hitCrosshairTexture.width, hitCrosshairTexture.height), hitCrosshairTexture); } ^Replace this in the "scoreManager" script. var maximumHitPoints = 100.0; var hitPoints = 100.0; var deadReplacement : Rigidbody; var GOPos : GameObject; function ApplyDamage (damage : float) { if (hitPoints <= 0.0) return; // Apply damage hitPoints -= damage; // Are we dead? if (hitPoints <= 0.0) Replace(); } function Replace() { // If we have a dead barrel then replace ourselves with it! if (deadReplacement) { var dead : Rigidbody = Instantiate(deadReplacement, GOPos.transform.position, GOPos.transform.rotation); // For better effect we assign the same velocity to the exploded barrel dead.rigidbody.velocity = rigidbody.velocity; dead.angularVelocity = rigidbody.angularVelocity; } // Destroy ourselves Destroy(gameObject); } ^This with "zombiedamage"script Weapon scripts(In English): /** * Script written by OMA [www.armedunity.com] // edited by BRMASTERGAMES * Edited in English by Ryan199Gamer **/ @script ExecuteInEditMode() enum fireMode { none, semi, auto, burst, launcher} @HideInInspector var currentMode = fireMode.semi; var firstMode = fireMode.semi; var secondMode = fireMode.launcher; enum Ammo { Magazines, Bullets } var ammoMode : Ammo = Ammo.Magazines; var canReloadLauncher : boolean = false; // Weapon Name // var WeaponName : String; var Bala : GameObject; var soundDraw : AudioClip; var soundFire : AudioClip; var soundReload : AudioClip; var soundEmpty : AudioClip; var switchModeSound : AudioClip; var weaponAnim : GameObject; var Concrete : GameObject; var Wood : GameObject; var Metal : GameObject; var Dirt : GameObject; var glass : GameObject; var Blood : GameObject; var BloodMutant : GameObject; var untagged : GameObject; var layerMask : LayerMask; var muzzleFlash : Renderer; var muzzleLight : Light; var damage : int = 50; var bulletsPerMag : int = 50; var magazines : int = 5; private var fireRate : float = 0.1; var fireRateFirstMode : float = 0.1; var fireRateSecondMode : float = 0.1; var reloadTime : float = 3.0; var reloadAnimSpeed : float = 1.2; var drawTime : float = 1.5; var range : float = 250.0; var force : float = 200.0; //Weapon accuracy private var baseInaccuracy : float; var baseInaccuracyAIM : float = 0.005; var baseInaccuracyHIP : float = 1.5; var inaccuracyIncreaseOverTime : float = 0.2; var inaccuracyDecreaseOverTime : float = 0.5; private var maximumInaccuracy : float; var maxInaccuracyHIP : float = 5.0; var maxInaccuracyAIM : float = 1.0; private var triggerTime : float = 0.05; //Aiming var hipPosition : Vector3; var aimPosition : Vector3; private var aiming : boolean; private var curVect : Vector3; var aimSpeed : float = 0.25; var animRun : boolean; //Field Of View var zoomSpeed : float = 0.5; var FOV : int = 40; private var bulletsLeft : int = 0; private var m_LastFrameShot : int = -10; private var nextFireTime : float = 0.0; @HideInInspector var reloading : boolean; private var draw : boolean; private var weaponCamera : GameObject; private var mainCamera : GameObject; private var playing : boolean = false; @HideInInspector var selected : boolean = false; private var player : GameObject; private var isFiring : boolean = false; private var bursting : boolean = false; //Burst var shotsPerBurst : int = 3; var burstTime : float = 0.07; //GUI var mySkin : GUISkin; //Launcher var projectilePrefab : Rigidbody; var projectileSpeed = 30.0; var projectiles = 20; var launchPosition : GameObject; var fireLauncherAnimGO : GameObject; var soundReloadLauncher : AudioClip; private var launcjerReload : boolean = false; var launcherReloadTime : float = 2.0; var reloadlauncher : String = "reloadlauncher"; private var rocket : GameObject; //KickBack var kickGO : Transform; var kickUpside : float = 0.5; var kickSideways : float = 0.5; //Crosshair Textures var crosshairFirstModeHorizontal : Texture2D; var crosshairFirstModeVertical : Texture2D; var crosshairSecondMode : Texture2D; private var adjustMaxCroshairSize : float = 6.0; var CrosshairOn : boolean; //Switch Weapon Fire Modes private var canSwicthMode : boolean = true; var rotation : float; function Start(){ weaponCamera = GameObject.FindWithTag("WeaponCamera"); mainCamera = GameObject.FindWithTag("MainCamera"); player = GameObject.FindWithTag("Player"); muzzleFlash.enabled = false; muzzleLight.enabled = false; bulletsLeft = bulletsPerMag; currentMode = firstMode; fireRate = fireRateFirstMode; aiming = false; animRun = true; if(firstMode == fireMode.launcher){ rocket = GameObject.Find("RPGrocket"); } if(ammoMode == Ammo.Bullets){ magazines = magazines * bulletsPerMag; } } function Update(){ if(selected){ if(Input.GetButton("Run")){ animRun = false; CrosshairOn = false; } if(Input.GetButtonUp("Run")){ animRun = true; CrosshairOn = true; } if(animRun == true){ if (Input.GetButtonDown ("Fire")){ if(currentMode == fireMode.semi){ fireSemi(); } if(currentMode == fireMode.launcher){ fireLauncher(); } if(currentMode == fireMode.burst){ fireBurst(); } if(bulletsLeft > 0) isFiring = true; } if (Input.GetButton ("Fire")){ if(currentMode == fireMode.auto){ fireSemi(); if(bulletsLeft > 0) isFiring = true; } } if(Input.GetButton("Fire2") && Input.GetButton("Fire1") && bulletsLeft > 1){ aiming = false; } if(Input.GetButton("Fire") && bulletsLeft == 0){ Reload(); } if(bulletsLeft == 0){ Reload(); } if (Input.GetButtonDown ("Reload")){ Reload(); } } } if (Input.GetButton("Fire2") && !Input.GetButton ("Run") && !reloading){ if (!aiming){ aiming = true; curVect = aimPosition - transform.localPosition; } if (transform.localPosition != aimPosition && aiming){ if(Mathf.Abs(Vector3.Distance(transform.localPosition , aimPosition)) < curVect.magnitude/aimSpeed * Time.deltaTime){ transform.localPosition = aimPosition; } else { transform.localPosition += curVect/aimSpeed * Time.deltaTime; } } } else { if (aiming){ aiming = false; curVect = hipPosition - transform.localPosition; /* var go = GetComponentsInChildren(Renderer); for( var g : Renderer in go){ if (g.name != "muzzle_flash") g.renderer.enabled = true; } */ } if(Mathf.Abs(Vector3.Distance(transform.localPosition , hipPosition)) < curVect.magnitude/aimSpeed * Time.deltaTime){ transform.localPosition = hipPosition; }else{ transform.localPosition += curVect/aimSpeed * Time.deltaTime; } } if(aiming){ maximumInaccuracy = maxInaccuracyAIM; baseInaccuracy = baseInaccuracyAIM; mainCamera.camera.fieldOfView -= FOV * Time.deltaTime/zoomSpeed; if(mainCamera.camera.fieldOfView < FOV){ mainCamera.camera.fieldOfView = FOV; } weaponCamera.camera.fieldOfView -= 40 * Time.deltaTime/zoomSpeed; if(weaponCamera.camera.fieldOfView < 40){ weaponCamera.camera.fieldOfView = 40; } }else{ maximumInaccuracy = maxInaccuracyHIP; baseInaccuracy = baseInaccuracyHIP; mainCamera.camera.fieldOfView += 60 * Time.deltaTime/0.5; if(mainCamera.camera.fieldOfView > 60){ mainCamera.camera.fieldOfView = 60; } weaponCamera.camera.fieldOfView += 50 * Time.deltaTime/0.5; if(weaponCamera.camera.fieldOfView > 50){ weaponCamera.camera.fieldOfView = 50; } } if(player.rigidbody.velocity.magnitude > 3.0){ triggerTime += inaccuracyDecreaseOverTime; } if(isFiring){ triggerTime += inaccuracyIncreaseOverTime; }else{ if(player.rigidbody.velocity.magnitude < 3.0) triggerTime -= inaccuracyDecreaseOverTime; } if (triggerTime >= maximumInaccuracy) { triggerTime = maximumInaccuracy; } if (triggerTime <= baseInaccuracy) { triggerTime = baseInaccuracy; } if(nextFireTime > Time.time){ isFiring = false; } if(Input.GetButtonDown("switchFireMode") && secondMode != fireMode.none && canSwicthMode){ if(currentMode != firstMode){ FirstFireMode(); }else{ SecondFireMode(); } } } function LateUpdate(){ if (m_LastFrameShot == Time.frameCount){ muzzleFlash.transform.localRotation = Quaternion.AngleAxis(Random.value * 360, Vector3.forward); muzzleFlash.enabled = true; muzzleLight.enabled = true; }else{ muzzleFlash.enabled = false; muzzleLight.enabled = false; } } function OnGUI (){ if(selected){ GUI.skin = mySkin; var style1 = mySkin.customStyles[0]; if(ammoMode == Ammo.Magazines){ if(firstMode != fireMode.none && firstMode != fireMode.launcher || secondMode != fireMode.none && secondMode != fireMode.launcher){ GUI.Label (Rect(Screen.width - 200,Screen.height-35,200,80),"AMMO : "); GUI.Label (Rect(Screen.width - 110,Screen.height-35,200,80),"" + bulletsLeft, style1); GUI.Label (Rect(Screen.width - 80,Screen.height-35,200,80)," | " + magazines, style1); } } if(ammoMode == Ammo.Bullets){ if(firstMode != fireMode.none && firstMode != fireMode.launcher || secondMode != fireMode.none && secondMode != fireMode.launcher){ GUI.Label (Rect(Screen.width - 200,Screen.height-35,200,80),"AMMO : "); GUI.Label (Rect(Screen.width - 110,Screen.height-35,200,80),"" + bulletsLeft, style1); if(bulletsLeft < 6){ var style2 = mySkin.customStyles[1]; GUI.Label (Rect(Screen.width - 110,Screen.height-35,200,80),"" + bulletsLeft, style2); } GUI.Label (Rect(Screen.width - 80,Screen.height-35,200,80)," | " + magazines, style1); } } if(firstMode != fireMode.none || secondMode != fireMode.none){ GUI.Label (Rect(Screen.width - 200,Screen.height-65,200,80),"FireMode:"); GUI.Label (Rect(Screen.width - 110,Screen.height-65,200,80),"" + currentMode, style1); } if(secondMode == fireMode.launcher || firstMode == fireMode.launcher){ GUI.Label (Rect(Screen.width - 200,Screen.height-95,200,80),"GrenadeAmmo: "); GUI.Label (Rect(Screen.width - 110,Screen.height-95,200,80),"" + projectiles, style1); } if(CrosshairOn){ if(crosshairFirstModeHorizontal != null){ if(currentMode != fireMode.launcher){ var w = crosshairFirstModeHorizontal.width; var h = crosshairFirstModeHorizontal.height; position1 = Rect((Screen.width + w)/2 + (triggerTime * adjustMaxCroshairSize),(Screen.height - h)/2, w, h); position2 = Rect((Screen.width - w)/2,(Screen.height + h)/2 + (triggerTime * adjustMaxCroshairSize), w, h); position3 = Rect((Screen.width - w)/2 - (triggerTime * adjustMaxCroshairSize) - w,(Screen.height - h )/2, w, h); position4 = Rect((Screen.width - w)/2,(Screen.height - h)/2 - (triggerTime * adjustMaxCroshairSize) - h, w, h); if (!aiming) { GUI.DrawTexture(position1, crosshairFirstModeHorizontal); //Right GUI.DrawTexture(position2, crosshairFirstModeVertical); //Up GUI.DrawTexture(position3, crosshairFirstModeHorizontal); //Left GUI.DrawTexture(position4, crosshairFirstModeVertical); //Down } } } if(crosshairSecondMode != null){ if(currentMode == fireMode.launcher){ var width = crosshairSecondMode.width/2; var height = crosshairSecondMode.height/2; position = Rect((Screen.width - width)/2,(Screen.height - height )/2, width, height); if (!aiming) { GUI.DrawTexture(position, crosshairSecondMode); } } } } } } function FirstFireMode(){ canSwicthMode = false; selected = false; weaponAnim.animation.Rewind("SwitchAnim"); weaponAnim.animation.Play("SwitchAnim"); audio.clip = switchModeSound; audio.Play(); yield WaitForSeconds(0.6); currentMode = firstMode; fireRate = fireRateFirstMode; selected = true; canSwicthMode = true; } function SecondFireMode(){ canSwicthMode = false; selected = false; audio.clip = switchModeSound; audio.Play(); weaponAnim.animation.Play("SwitchAnim"); yield WaitForSeconds(0.6); currentMode = secondMode; fireRate = fireRateSecondMode; selected = true; canSwicthMode = true; } function fireSemi (){ if (reloading || bulletsLeft <= 0){ if(bulletsLeft == 0){ OutOfAmmo(); } return; } if (Time.time - fireRate > nextFireTime) nextFireTime = Time.time - Time.deltaTime; while(nextFireTime < Time.time){ fireOneBullet(); nextFireTime = Time.time + fireRate; } } function fireLauncher (){ if (reloading || projectiles <= 0){ if(projectiles == 0){ OutOfAmmo(); } return; } if (Time.time - fireRate > nextFireTime) nextFireTime = Time.time - Time.deltaTime; while(nextFireTime < Time.time){ fireProjectile(); nextFireTime = Time.time + fireRate; } } function fireBurst (){ var shotCounter : int = 0; if (reloading || bursting || bulletsLeft <= 0){ if(bulletsLeft <= 0){ OutOfAmmo(); } return; } if (Time.time - fireRate > nextFireTime) nextFireTime = Time.time - Time.deltaTime; if(Time.time > nextFireTime){ while (shotCounter < shotsPerBurst){ bursting = true; shotCounter++; if (bulletsLeft > 0){ fireOneBullet(); } yield WaitForSeconds(burstTime); } nextFireTime = Time.time + fireRate; } bursting = false; } function fireOneBullet (){ if (nextFireTime > Time.time || draw){ if(bulletsLeft <= 0){ OutOfAmmo(); } return; } var direction = gameObject.transform.TransformDirection(Vector3(Random.Range(-0.01, 0.01) * triggerTime, Random.Range(-0.01, 0.01) * triggerTime,1)); var hit : RaycastHit; var position = transform.parent.position; if (Physics.Raycast(position, direction, hit, range, layerMask.value)) { var contact = hit.point; var rotation = Quaternion.FromToRotation(Vector3.up, hit.normal); if (hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } if (hit.transform.tag == "Untagged") { var default1 = Instantiate (untagged, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); default1.transform.parent = hit.transform; } if (hit.transform.tag == "Concrete") { var bulletHole = Instantiate (Concrete, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); bulletHole.transform.parent = hit.transform; } if (hit.transform.tag == "Wood") { var woodHole = Instantiate (Wood, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); woodHole.transform.parent = hit.transform; } if (hit.transform.tag == "Metal") { var metalHole = Instantiate (Metal, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); metalHole.transform.parent = hit.transform; } if (hit.transform.tag == "Dirt") { var dirtHole = Instantiate (Dirt, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); dirtHole.transform.parent = hit.transform; } if (hit.transform.tag == "glass") { var glassHole = Instantiate (glass, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); glassHole.transform.parent = hit.transform; } if (hit.transform.tag == "canBeUsed") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); } if (hit.transform.tag == "Enemy") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); yield WaitForSeconds(0.01); var bloodHole = Instantiate (Blood, contact, rotation) as GameObject; if(Physics.Raycast (position, direction, hit, range, layerMask.value)){ if(hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } } } if (hit.transform.tag == "EnemyMutant") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); yield WaitForSeconds(0.02); var bloodMutantHole = Instantiate (BloodMutant, contact, rotation) as GameObject; if(Physics.Raycast (position, direction, hit, range, layerMask.value)){ if(hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } } } } PlayAudioClip(soundFire, transform.position, 0.7); m_LastFrameShot = Time.frameCount; weaponAnim.animation.Rewind("Fire"); weaponAnim.animation.Play("Fire"); KickBack(); bulletsLeft--; } function PlayAudioClip (clip : AudioClip, position : Vector3, volume : float) { var go = new GameObject ("Bala som"); go.transform.position = position; var source : AudioSource = go.AddComponent (AudioSource); source.clip = clip; source.volume = volume; source.pitch = Random.Range(0.95,1.05); source.Play (); Destroy (go, clip.length); return source; } function fireProjectile (){ if (projectiles < 1 || draw || launcjerReload){ return; } var instantiatedProjectile : Rigidbody = Instantiate (projectilePrefab, launchPosition.transform.position, launchPosition.transform.rotation); fireLauncherAnimGO.animation.Play("FireGL"); instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0, 0, projectileSpeed)); Physics.IgnoreCollision(instantiatedProjectile.collider, gameObject.FindWithTag("Player").transform.root.collider); projectiles--; if(canReloadLauncher) ReloadLauncher(); } function OutOfAmmo(){ if(reloading || playing) return; playing = true; PlayAudioClip(soundEmpty, transform.position, 0.7); yield WaitForSeconds(0.2); playing = false; } //For RPG function ReloadLauncher(){ if(projectiles > 0){ launcjerReload = true; canSwicthMode = false; DisableProjectileRenderer(); yield WaitForSeconds(0.5); audio.PlayOneShot(soundReloadLauncher); weaponAnim.animation[reloadlauncher].speed = 1.2; weaponAnim.animation.Play(reloadlauncher); yield WaitForSeconds(launcherReloadTime); canSwicthMode = true; launcjerReload = false; }else{ if(rocket != null && projectiles == 0){ rocket.renderer.enabled = false; } } } function DisableProjectileRenderer(){ if(rocket != null){ rocket.renderer.enabled = false; } yield WaitForSeconds(launcherReloadTime/1.5); if(rocket != null){ rocket.renderer.enabled = true; } } function EnableProjectileRenderer(){ if(rocket != null){ rocket.renderer.enabled = true; } } function Reload (){ if(reloading) return; if(ammoMode == Ammo.Magazines){ reloading = true; canSwicthMode = false; if (magazines > 0 && bulletsLeft != bulletsPerMag) { weaponAnim.animation["Reload"].speed = reloadAnimSpeed; weaponAnim.animation.Play("Reload", PlayMode.StopAll); weaponAnim.animation.CrossFade("Reload"); audio.clip = soundReload; audio.Play(); yield WaitForSeconds(reloadTime); magazines --; bulletsLeft = bulletsPerMag; } reloading = false; canSwicthMode = true; isFiring = false; } if(ammoMode == Ammo.Bullets){ if(magazines > 0 && bulletsLeft != bulletsPerMag){ if(magazines > bulletsPerMag){ canSwicthMode = false; reloading = true; weaponAnim.animation["Reload"].speed = reloadAnimSpeed; weaponAnim.animation.Play("Reload", PlayMode.StopAll); weaponAnim.animation.CrossFade("Reload"); audio.clip = soundReload; audio.Play(); yield WaitForSeconds(reloadTime); magazines -= bulletsPerMag - bulletsLeft; bulletsLeft = bulletsPerMag; canSwicthMode = true; reloading = false; return; }else{ canSwicthMode = false; reloading = true; weaponAnim.animation["Reload"].speed = reloadAnimSpeed; weaponAnim.animation.Play("Reload", PlayMode.StopAll); weaponAnim.animation.CrossFade("Reload"); audio.clip = soundReload; audio.Play(); yield WaitForSeconds(reloadTime); var bullet = Mathf.Clamp(bulletsPerMag, magazines, bulletsLeft + magazines); magazines -= (bullet - bulletsLeft); bulletsLeft = bullet; canSwicthMode = true; reloading = false; return; } } } } function KickBack() { kickGO.localRotation = Quaternion.Euler(kickGO.localRotation.eulerAngles - Vector3(kickUpside, Random.Range(-kickSideways, kickSideways), 0)); } function DrawWeapon(){ addair = gameObject.Find("Player").GetComponent("RigidController"); draw = true; canSwicthMode = false; audio.clip = soundDraw; audio.Play(); weaponAnim.animation.Play("Draw", PlayMode.StopAll); weaponAnim.animation.CrossFade("Draw"); yield WaitForSeconds(drawTime); draw = false; reloading = false; canSwicthMode = true; selected = true; } function Deselect(){ selected = false; animRun = true; CrosshairOn = true; mainCamera.camera.fieldOfView = 60; weaponCamera.camera.fieldOfView = 50; transform.localPosition = hipPosition; } ^"WeaponScriptNew" script /** * Script written by OMA [www.armedunity.com] * Edited for survival horror by Ryan199Gamer **/ //@script ExecuteInEditMode() var WeaponName : String; var soundDraw : AudioClip; var soundFire : AudioClip; var soundReload : AudioClip; var soundGO : GameObject; var soundEmpty : AudioClip; var weaponAnim : GameObject; var Concrete : GameObject; var Wood : GameObject; var Metal : GameObject; var glass : GameObject; var Dirt : GameObject; var Blood : GameObject; var BloodMutant : GameObject; var untagged : GameObject; var layerMask : LayerMask; var muzzleFlash : Renderer; var muzzleLight : Light; var pelletsPerShot : int = 10; var damage : int = 50; var bulletsPerMag : int = 50; var magazines : int = 5; var fireRate : float = 0.1; var reloadTime : float = 3.0; var drawTime : float = 1.5; var range : float = 250.0; var force : float = 200.0; var inacuracy : float = 0.2; //Aiming var hipPosition : Vector3; var aimPosition : Vector3; private var aiming : boolean; private var curVect : Vector3; var aimSpeed : float = 0.25; //Field Of View var zoomSpeed : float = 0.5; var FOV : int = 40; private var bulletsLeft : int = 0; private var m_LastFrameShot : int = -10; private var nextFireTime : float = 0.0; private var reloading : boolean; private var draw : boolean; private var weaponCamera : GameObject; private var mainCamera : GameObject; private var playing : boolean = false; @HideInInspector var selected : boolean = false; //private var player : GameObject; //GUI var mySkin : GUISkin; var animRun : boolean; //KickBack var kickGO : Transform; var kickUpside : float = 0.5; var kickSideways : float = 0.5; //Crosshair Textures var crosshair : Texture2D; function Start(){ weaponCamera = GameObject.FindWithTag("WeaponCamera"); mainCamera = GameObject.FindWithTag("MainCamera"); //player = GameObject.FindWithTag("Player"); muzzleFlash.enabled = false; muzzleLight.enabled = false; bulletsLeft = bulletsPerMag; aiming = false; animRun = true; } function Update(){ if(selected){ if(Input.GetButton("Run")){ animRun = false; } if(Input.GetButtonUp("Run")){ animRun = true; } if(bulletsLeft == 0){ Reload(); } if(animRun == true){ if (Input.GetButtonDown ("Fire")){ FireShotgun(); } if (Input.GetButtonDown ("Reload")){ Reload(); } } } if (Input.GetButton("Fire2") && !Input.GetButton ("Run") && !reloading){ if (!aiming){ aiming = true; curVect = aimPosition - transform.localPosition; } if (transform.localPosition != aimPosition && aiming){ if(Mathf.Abs(Vector3.Distance(transform.localPosition , aimPosition)) < curVect.magnitude/aimSpeed * Time.deltaTime){ transform.localPosition = aimPosition; } else { transform.localPosition += curVect/aimSpeed * Time.deltaTime; } } } else { if (aiming){ aiming = false; curVect = hipPosition-transform.localPosition; var go = GetComponentsInChildren(Renderer); for( var g : Renderer in go){ if (g.name != "muzzle_flash") g.renderer.enabled = true; } } if(Mathf.Abs(Vector3.Distance(transform.localPosition , hipPosition)) < curVect.magnitude/aimSpeed * Time.deltaTime){ transform.localPosition = hipPosition; }else{ transform.localPosition += curVect/aimSpeed * Time.deltaTime; } } if(aiming){ mainCamera.camera.fieldOfView -= FOV * Time.deltaTime/zoomSpeed; if(mainCamera.camera.fieldOfView < FOV){ mainCamera.camera.fieldOfView = FOV; } weaponCamera.camera.fieldOfView -= 40 * Time.deltaTime/zoomSpeed; if(weaponCamera.camera.fieldOfView < 40){ weaponCamera.camera.fieldOfView = 40; } }else{ mainCamera.camera.fieldOfView += 60 * Time.deltaTime/0.5; if(mainCamera.camera.fieldOfView > 60){ mainCamera.camera.fieldOfView = 60; } weaponCamera.camera.fieldOfView += 50 * Time.deltaTime/0.5; if(weaponCamera.camera.fieldOfView > 50){ weaponCamera.camera.fieldOfView = 50; } } } function LateUpdate(){ if (m_LastFrameShot == Time.frameCount){ muzzleFlash.transform.localRotation = Quaternion.AngleAxis(Random.value * 360, Vector3.forward); muzzleFlash.enabled = true; muzzleLight.enabled = true; }else{ muzzleFlash.enabled = false; muzzleLight.enabled = false; } } function OnGUI (){ if(selected){ GUI.skin = mySkin; var style1 = mySkin.customStyles[0]; GUI.Label (Rect(Screen.width - 200,Screen.height-35,200,80),"AMMO : "); GUI.Label (Rect(Screen.width - 110,Screen.height-35,200,80),"" + bulletsLeft, style1); GUI.Label (Rect(Screen.width - 80,Screen.height-35,200,80)," / " + magazines); if(bulletsLeft < 2){ var style2 = mySkin.customStyles[3]; GUI.Label (Rect(Screen.width - 110,Screen.height-35,200,80),"" + bulletsLeft, style2); } if(crosshair != null){ var w = crosshair.width/2; var h = crosshair.height/2; position = Rect((Screen.width - w)/2,(Screen.height - h )/2, w, h); if (!aiming) { GUI.DrawTexture(position, crosshair); } } } } function FireShotgun (){ if (reloading || bulletsLeft <= 0 || draw){ if(bulletsLeft == 0){ OutOfAmmo(); } return; } var pellets : int = 0; if (Time.time - fireRate > nextFireTime) nextFireTime = Time.time - Time.deltaTime; if(Time.time > nextFireTime){ while (pellets < pelletsPerShot){ FireOneShot(); pellets++; } bulletsLeft--; nextFireTime = Time.time + fireRate; KickBack(); } } function FireOneShot (){ var direction = gameObject.transform.TransformDirection(Vector3(Random.Range(-0.01, 0.01) * inacuracy, Random.Range(-0.01, 0.01) * inacuracy,1)); var hit : RaycastHit; var position = transform.parent.position; if (Physics.Raycast (position, direction, hit, range, layerMask.value)) { var contact = hit.point; var rotation = Quaternion.FromToRotation(Vector3.up, hit.normal); if (hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } if (hit.transform.tag == "Untagged") { var default1 = Instantiate (untagged, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); default1.transform.parent = hit.transform; } if (hit.transform.tag == "Concrete") { var bulletHole = Instantiate (Concrete, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); bulletHole.transform.parent = hit.transform; } if (hit.transform.tag == "Wood") { var woodHole = Instantiate (Wood, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); woodHole.transform.parent = hit.transform; } if (hit.transform.tag == "Metal") { var metalHole = Instantiate (Metal, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); metalHole.transform.parent = hit.transform; } if (hit.transform.tag == "glass") { var glassHole = Instantiate (glass, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); glassHole.transform.parent = hit.transform; } if (hit.transform.tag == "Dirt") { var dirtHole = Instantiate (Dirt, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); dirtHole.transform.parent = hit.transform; } if (hit.transform.tag == "canBeUsed") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); } if (hit.transform.tag == "Enemy") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); yield WaitForSeconds(0.03); var bloodHole = Instantiate (Blood, contact, rotation) as GameObject; if(Physics.Raycast (position, direction, hit, range, layerMask.value)){ if(hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } } } if (hit.transform.tag == "EnemyMutant") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); yield WaitForSeconds(0.03); var bloodMutantHole = Instantiate (BloodMutant, contact, rotation) as GameObject; if(Physics.Raycast (position, direction, hit, range, layerMask.value)){ if(hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } } } } if (audio) { audio.clip = soundFire; audio.Play(); } m_LastFrameShot = Time.frameCount; weaponAnim.animation.Rewind("ShotgunFire"); weaponAnim.animation.Play("ShotgunFire"); } function OutOfAmmo(){ if(reloading || playing) return; playing = true; soundGO.audio.clip = soundEmpty; soundGO.audio.volume = 0.7; soundGO.audio.Play(); weaponAnim.animation["Fire"].speed = 2.0; weaponAnim.animation.Play("Fire"); yield WaitForSeconds(0.2); playing = false; } function Reload (){ if(reloading) return; reloading = true; if (magazines > 0 && bulletsLeft < bulletsPerMag) { weaponAnim.animation["ShotgunReload"].speed = .8; weaponAnim.animation.Play("ShotgunReload", PlayMode.StopAll); weaponAnim.animation.CrossFade("ShotgunReload"); audio.PlayOneShot(soundReload); yield WaitForSeconds(reloadTime); magazines--; bulletsLeft = bulletsPerMag; } reloading = false; } function KickBack() { kickGO.localRotation = Quaternion.Euler(kickGO.localRotation.eulerAngles - Vector3(kickUpside, Random.Range(-kickSideways, kickSideways), 0)); } function DrawWeapon(){ draw = true; audio.clip = soundDraw; audio.Play(); weaponAnim.animation.Play("Draw", PlayMode.StopAll); weaponAnim.animation.CrossFade("Draw"); yield WaitForSeconds(drawTime); draw = false; reloading = false; selected = true; } function Deselect(){ selected = false; mainCamera.camera.fieldOfView = 60; weaponCamera.camera.fieldOfView = 50; transform.localPosition = hipPosition; } ^"ShotGunScriptNew"Script /** * Script written by OMA [www.armedunity.com] **/ enum FireMode { semi, auto } var Mode = FireMode.semi; var WeaponName : String; var soundFire : AudioClip; var soundReload : AudioClip; var soundEmpty : AudioClip; var soundDraw : AudioClip; var weaponAnim : GameObject; var Concrete : GameObject; var Wood : GameObject; var Metal : GameObject; var Dirt : GameObject; var glass : GameObject; var Blood : GameObject; var BloodMutant : GameObject; var untagged : GameObject; var layerMask : LayerMask; var muzzleFlash : Renderer; var muzzleLight : Light; var damage : int = 50; var bulletsPerMag : int = 50; var magazines : int = 5; var reloadTime : float = 2; var drawTime = 1.0; private var bulletsLeft = 0; var fireRate : float = 0.1; var range : float = 1000; var force : float = 500; //Weapon accuracy private var baseInaccuracy : float; var inaccuracyIncreaseOverTime : float = 0.01; var inaccuracyDecreaseOverTime : float = 0.5; private var maximumInaccuracy : float; private var triggerTime : float = 0.05; var baseInaccuracyAIM : float = 0.005; var baseInaccuracyHIP : float = 1.5; var maxInaccuracyHIP : float = 5.0; var maxInaccuracyAIM : float = 1.0; //Aiming var hipPosition : Vector3; var aimPosition : Vector3; private var aiming : boolean; private var curVect : Vector3; var CrossOn : boolean; var aimSpeed : float = 0.25; var scopeTime : float; private var inScope : boolean = false; var scopeTexture : Texture; //Field Of View var zoomSpeed : float = 0.5; var FOV : int = 40; //KickBack var kickGO : Transform; var kickUpside : float = 0.5; var kickSideways : float = 0.5; //GUI var mySkin : GUISkin; var animRun : boolean; private var m_LastFrameShot : int = -1; private var nextFireTime = 0.0; private var reloading : boolean; private var draw : boolean; var weaponCamera : GameObject; var mainCamera : GameObject; private var player : GameObject; @HideInInspector var selected : boolean = false; private var isFiring : boolean = false; private var playing : boolean = false; //Crosshair Textures var crosshairFirstModeHorizontal : Texture2D; var crosshairFirstModeVertical : Texture2D; private var adjustMaxCroshairSize : float = 6.0; function Start(){ weaponCamera = GameObject.FindWithTag("WeaponCamera"); mainCamera = GameObject.FindWithTag("MainCamera"); player = GameObject.FindWithTag("Player"); muzzleFlash.enabled = false; muzzleLight.enabled = false; bulletsLeft = bulletsPerMag; aiming = false; animRun = true; rossOn = true; } function Update() { if(selected){ if(Input.GetButton("Run")){ animRun = false; CrossOn = false; } if(Input.GetButtonUp("Run")){ animRun = true; CrossOn = true; } if(animRun == true){ if(Input.GetButtonDown ("Fire")){ if(Mode == FireMode.semi){ fireSniper(); } if(bulletsLeft > 0) isFiring = true; } if (Input.GetButton ("Fire")){ if(Mode == FireMode.auto){ fireSniper(); if(bulletsLeft > 0) isFiring = true; } } } if(Input.GetButton("Fire") && bulletsLeft == 0){ Reload(); } if(bulletsLeft == 0){ Reload(); } if (Input.GetButtonDown ("Reload")){ Reload(); } if (Input.GetButton("Fire2") && !Input.GetButton("Run") && !reloading){ if (!aiming){ aiming = true; curVect = aimPosition - transform.localPosition; scopeTime = Time.time + aimSpeed; } if (transform.localPosition != aimPosition && aiming){ if(Mathf.Abs(Vector3.Distance(transform.localPosition , aimPosition)) < curVect.magnitude/aimSpeed * Time.deltaTime){ transform.localPosition = aimPosition; } else { transform.localPosition += curVect/aimSpeed * Time.deltaTime; } } if (Time.time >= scopeTime && !inScope){ inScope = true; var gos = GetComponentsInChildren(Renderer); for( var go : Renderer in gos){ go.renderer.enabled = false; } } } else { if (aiming){ aiming = false; inScope = false; curVect= hipPosition-transform.localPosition; var go = GetComponentsInChildren(Renderer); for( var g : Renderer in go){ if (g.name != "muzzle_flash") g.renderer.enabled = true; } } if(Mathf.Abs(Vector3.Distance(transform.localPosition , hipPosition)) < curVect.magnitude/aimSpeed*Time.deltaTime){ transform.localPosition = hipPosition; }else{ transform.localPosition += curVect/aimSpeed*Time.deltaTime; } } if(inScope){ maximumInaccuracy = maxInaccuracyAIM; baseInaccuracy = baseInaccuracyAIM; mainCamera.camera.fieldOfView -= FOV * Time.deltaTime/zoomSpeed; if(mainCamera.camera.fieldOfView < FOV){ mainCamera.camera.fieldOfView = FOV; } weaponCamera.camera.fieldOfView -= 40 * Time.deltaTime/zoomSpeed; if(weaponCamera.camera.fieldOfView < 40){ weaponCamera.camera.fieldOfView = 40; } }else{ maximumInaccuracy = maxInaccuracyHIP; baseInaccuracy = baseInaccuracyHIP; mainCamera.camera.fieldOfView += 60 * Time.deltaTime/0.2; if(mainCamera.camera.fieldOfView > 60){ mainCamera.camera.fieldOfView = 60; } weaponCamera.camera.fieldOfView += 50 * Time.deltaTime/0.2; if(weaponCamera.camera.fieldOfView > 50){ weaponCamera.camera.fieldOfView = 50; } } if(player.rigidbody.velocity.magnitude > 3.0){ triggerTime += inaccuracyDecreaseOverTime; } if(isFiring){ triggerTime += inaccuracyIncreaseOverTime; }else{ if(player.rigidbody.velocity.magnitude < 3.0) triggerTime -= inaccuracyDecreaseOverTime; } if (triggerTime >= maximumInaccuracy) { triggerTime = maximumInaccuracy; } if (triggerTime <= baseInaccuracy) { triggerTime = baseInaccuracy; } if(nextFireTime > Time.time){ isFiring = false; } } } function LateUpdate(){ if (m_LastFrameShot == Time.frameCount && !inScope){ muzzleFlash.transform.localRotation = Quaternion.AngleAxis(Random.value * 360, Vector3.forward); muzzleFlash.enabled = true; muzzleLight.enabled = true; }else{ muzzleFlash.enabled = false; muzzleLight.enabled = false; } } function OnGUI (){ if(selected){ GUI.skin = mySkin; var style1 = mySkin.customStyles[0]; if(selected){ GUI.Label (Rect(Screen.width - 200,Screen.height-35,200,80),"Ammo : "); GUI.Label (Rect(Screen.width - 110,Screen.height-35,200,80),"" + bulletsLeft, style1); GUI.Label (Rect(Screen.width - 80,Screen.height-35,200,80)," / " + magazines); } if(bulletsLeft < 4){ var style2 = mySkin.customStyles[3]; GUI.Label (Rect(Screen.width - 110,Screen.height-35,200,80),"" + bulletsLeft, style2); } if(scopeTexture != null && inScope){ GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height), scopeTexture, ScaleMode.StretchToFill); }else{ if(CrossOn){ if(crosshairFirstModeHorizontal != null){ var w = crosshairFirstModeHorizontal.width; var h = crosshairFirstModeHorizontal.height; position1 = Rect((Screen.width + w)/2 + (triggerTime * adjustMaxCroshairSize),(Screen.height - h)/2, w, h); position2 = Rect((Screen.width - w)/2,(Screen.height + h)/2 + (triggerTime * adjustMaxCroshairSize), w, h); position3 = Rect((Screen.width - w)/2 - (triggerTime * adjustMaxCroshairSize) - w,(Screen.height - h )/2, w, h); position4 = Rect((Screen.width - w)/2,(Screen.height - h)/2 - (triggerTime * adjustMaxCroshairSize) - h, w, h); if (!aiming) { GUI.DrawTexture(position1, crosshairFirstModeHorizontal); //Right GUI.DrawTexture(position2, crosshairFirstModeVertical); //Up GUI.DrawTexture(position3, crosshairFirstModeHorizontal); //Left GUI.DrawTexture(position4, crosshairFirstModeVertical); //Down } } } } } } function fireSniper (){ if (reloading || bulletsLeft <= 0){ if(bulletsLeft == 0){ OutOfAmmo(); } return; } if (Time.time - fireRate > nextFireTime) nextFireTime = Time.time - Time.deltaTime; while(nextFireTime < Time.time){ fireOneBullet(); nextFireTime = Time.time + fireRate; } } function fireOneBullet (){ if (nextFireTime > Time.time || draw){ if(bulletsLeft <= 0){ OutOfAmmo(); } return; } var direction = mainCamera.transform.TransformDirection(Vector3(Random.Range(-0.05, 0.05) * triggerTime/3, Random.Range(-0.05, 0.05) * triggerTime/3,1)); var hit : RaycastHit; var position = transform.parent.position; if (Physics.Raycast (position, direction, hit, range, layerMask.value)) { var contact = hit.point; var rotation = Quaternion.FromToRotation(Vector3.up, hit.normal); if (hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } if(hit.transform.tag == "Fracture"){ hit.transform.GetComponent("SimpleFracture").Fracture(contact,direction, true); } if (hit.transform.tag == "Untagged") { var default1 = Instantiate (untagged, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); default1.transform.parent = hit.transform; } if (hit.transform.tag == "Concrete") { var bulletHole = Instantiate (Concrete, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); bulletHole.transform.parent = hit.transform; } if (hit.transform.tag == "Wood") { var woodHole = Instantiate (Wood, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); woodHole.transform.parent = hit.transform; } if (hit.transform.tag == "glass") { var glassHole = Instantiate (glass, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); glassHole.transform.parent = hit.transform; } if (hit.transform.tag == "Metal") { var metalHole = Instantiate (Metal, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); metalHole.transform.parent = hit.transform; } if (hit.transform.tag == "Dirt") { var dirtHole = Instantiate (Dirt, contact, rotation) as GameObject; hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); dirtHole.transform.parent = hit.transform; } if (hit.transform.tag == "canBeUsed") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); } if (hit.transform.tag == "Enemy") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); yield WaitForSeconds(0.02); var bloodHole = Instantiate (Blood, contact, rotation) as GameObject; if(Physics.Raycast (position, direction, hit, range, layerMask.value)){ if(hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } } } if (hit.transform.tag == "EnemyMutant") { hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); yield WaitForSeconds(0.02); var bloodMutantHole = Instantiate (BloodMutant, contact, rotation) as GameObject; if(Physics.Raycast (position, direction, hit, range, layerMask.value)){ if(hit.rigidbody){ hit.rigidbody.AddForceAtPosition(force * direction, hit.point); } } } } PlayAudioClip(soundFire, transform.position, 0.7); m_LastFrameShot = Time.frameCount; weaponAnim.animation.Rewind("sniperFire"); weaponAnim.animation.Play("sniperFire"); bulletsLeft--; KickBack(); } function OutOfAmmo(){ if(reloading || playing) return; playing = true; yield WaitForSeconds(0.2); PlayAudioClip(soundEmpty, transform.position, 0.7); yield WaitForSeconds(0.2); playing = false; } function PlayAudioClip (clip : AudioClip, position : Vector3, volume : float) { var go = new GameObject ("One shot audio"); go.transform.position = position; var source : AudioSource = go.AddComponent (AudioSource); source.clip = clip; source.volume = volume; source.pitch = Random.Range(0.95,1.05); source.Play (); Destroy (go, clip.length); return source; } function Reload (){ if(reloading) return; reloading = true; if (magazines > 0 && bulletsLeft < bulletsPerMag) { weaponAnim.animation["Reload"].speed = 1.0; weaponAnim.animation.Play("Reload", PlayMode.StopAll); weaponAnim.animation.CrossFade("Reload"); audio.clip = soundReload; audio.Play(); yield WaitForSeconds(reloadTime); magazines --; bulletsLeft = bulletsPerMag; } reloading = false; } function DrawWeapon(){ draw = true; audio.clip = soundDraw; audio.Play(); weaponAnim.animation.Play("Draw", PlayMode.StopAll); weaponAnim.animation.CrossFade("Draw"); yield WaitForSeconds(drawTime); draw = false; reloading = false; selected = true; } function KickBack() { kickGO.localRotation = Quaternion.Euler(kickGO.localRotation.eulerAngles - Vector3(kickUpside, Random.Range(-kickSideways, kickSideways), 0)); } function Deselect(){ selected = false; animRun = true; CrossOn = true; mainCamera.camera.fieldOfView = 60; weaponCamera.camera.fieldOfView = 50; inScope = false; transform.localPosition = hipPosition; var go = GetComponentsInChildren(Renderer); for( var g : Renderer in go){ if (g.name != "muzzle_flash") g.renderer.enabled = true; } } ^"SniperScript"Script And remove the "air attack" component from player if you want. HOPE THIS HELPS
  16. ryan199gamer

    Animations in FPS KIT 1.3.5.

    how do i add an animation to the player i want it to get up from a bed when the game starts . when i apply the animation , after the animation the camera gets stuck. my camera doesnt move right or left. please help.
  17. dragonslayer

    Nav Mesh In Fpskit?

    Im making a game using the fps kit 1.3.5 and I saw this thing called nav mesh for npc navigation in unity. Is there any way I can use this to make the zombie AI avoid obstacles? Thanks
  18. dragonslayer

    FPS kit 1.3.5 Zombie AI Help

    I want (When the fps kit 1.3.5 zombie is idle) the zombie to walk around randomly when the zombie has no target in sight. Also when I change the move speed of the AI script in the inspector it still keeps the speed for the zombie the same.
  19. I want to set up path finding for the zombies in fps Kit 1.3.5 using Rain Indie but I cant figure out how to use Rain. Does anyone know how to use rain and set up path finding for the zombies?
  20. dragonslayer

    OMA Fps Kit 1.3.5 Zombie Mecanim Help

    I am making a game with the Oma Fpskit 1.3.5 and i have some humanoid animations that I want to use on the zombie model. Is there any way (maybe using Mecanim) that I can use them and have them triggered by the AI script. Thanks
  21. darkpredator666

    barricades for zombies to break

    so far i have been using the recent fps kit from OMA and atm i want to be able to create barricades that zombies can would want to destroy but idk how to do this is there anything i can add to the zombie AI script (or a separate script attached to the zombies) that means that the zombies will attack anything (perhaps that is tagged barricade) and what would i have to write for the script to give the barricades health so that they take time to destroy and u can repair them (if they haven't been destroyed yet)? im still a bit noob-ish at programming...
  22. dragonslayer

    Adding weapons into FPSkit 1.3.5 HELP!!!

    Ok im trying to add weapons into the fps kit by replacing the models in weapon manager but for some reason all the models i put in are just floating outside the fps hands. Any help would be great! Thanks
  23. dragonslayer

    Fps Kit Door Trigger Text Help?

    Hey guys, So I have this door script (It's actually not mine I got it from desert fortress pack) and I'm using it with the FPS kit By OMA. I can't figure out how to add the "press e to use" gui that is on the weapon pickup and stuff. I want to figure out a way to add that gui to the door. Thanks! using UnityEngine; using System.Collections; //Instruction: //Make an empty game object and call it "Door" //Rename your 3D door model to "Body" //Parent a "Body" object to "Door" //Make sure thet a "Door" object is in left down corner of "Body" object. The place where a Door Hinge need be //Add a box collider to "Door" object and make it much bigger then the "Body" model, mark it trigger //Assign this script to a "Door" game object that have box collider with trigger enabled //Press "e" (Default) to open and close the door //Make sure the main character is tagged "player" public class open_door : MonoBehaviour { public float smooth = (float)2.0; public float DoorOpenAngle = (float)110.0; public float DoorCloseAngle = (float)0.0; public bool open = false; public bool enter = false; public string defined_key = "e"; // Update is called once per frame void Update () { if(open == true) { var target = Quaternion.Euler (transform.localRotation.x, DoorOpenAngle, transform.localRotation.z); // Dampen towards the target rotation transform.localRotation = Quaternion.Slerp(transform.localRotation, target, Time.deltaTime * smooth); } if(open == false) { var target1 = Quaternion.Euler (transform.localRotation.x, DoorCloseAngle, transform.localRotation.z); // Dampen towards the target rotation transform.localRotation = Quaternion.Slerp(transform.localRotation, target1, Time.deltaTime * smooth); } if(enter == true) { if(Input.GetKeyDown(defined_key)) { open = !open; } } } //Activate the Main function when player is near the door void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { //Debug.Log("Trigger Enter"); (enter) = true; } } //Deactivate the Main function when player is go away from door void OnTriggerExit (Collider other) { if (other.gameObject.tag == "Player") { //Debug.Log("Trigger Exit"); (enter) = false; } } //@youtube.com/user/maksimum654321 }
  24. gfhoihoi72

    Vehicle Problem FPSKit

    When I press E near a vehicle in OMA's FPSKit I can't get in, it says InvalidCastException: Cannot cast from source type to destination type. WehicleScript.GetIn () (at Assets/Resources/OldScripts/Vehicle scripts/WehicleScript.js:52) WehicleScript+$Action$479+$.MoveNext () (at Assets/Resources/OldScripts/Vehicle scripts/WehicleScript.js:42) UnityEngine.GameObject:BroadcastMessage(String) FPSCcameraScript:Update() (at Assets/Resources/OldScripts/Vehicle scripts/FPSCcameraScript.js:18) I didn't change anything in the original scripts. I hope someone can help me with this problem!
  25. Hey Guys , I Need Help , I Was wondering and trying to add animated legs to a FPC that I Got , How can I Add them , and Is the Torso of the player going to be visible or not
×