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

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


    • Introduce yourself
    • Discussions
    • Showcase
    • Need help?
    • Seeking team members?
    • Offtopic
    • unity3D | Example Projects
    • unity3D | Scripts
    • unity3D | Shaders
    • unity3D | Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
    • FPSKit Download
    • FPSKit Modifications/Tutorials
    • FPSKit WIP/Showcase
    • Discussions / Bug reports
    • Sell
    • Request
  • Photon's Tutorials
  • Busy People's Introductions
  • Mars' Modular Multiplayer Photon FPS Kit's Topics
  • Mars' Modular Multiplayer Photon FPS Kit's Reviews
  • Photon's Photon General
  • Photon's Showcase
  • Mars' Modular Multiplayer Photon FPS Kit's Updates
  • Mars' Modular Multiplayer Photon FPS Kit's Tutorials


  • Free Projects
  • Free Assets
  • Game Demos
  • Photon's Files


  • Community Calendar

Facebook URL

Twitter URL

IndieGoGo URL

Kickstarter URL


GreenLight URL



Found 22 results

  1. I wanna change the gun position and play running anim[In running anim the gun is swinging left and right] when Player press Right Shift key then the gun should goto running position and running rotation and when player release it then gun should come to its default position. I'm using Lerp and Quaternion in my script. I've added this script in my Parent of Gun[I hope you know what I mean See Screenshot]( Issue I have )When I press shift key then player's gun go to running position very slowly and when I release the key then gun is not coming to its initial position. So this is also causing me issue. Here is script. using UnityEngine; using System.Collections; public class Holder : MonoBehaviour { public Animation animation; public AnimationClip walk; public AnimationClip idle; public Vector3 runningPos; public Vector3 runningRot; public float lerpSpeed = 1.5f; public AnimationClip runninAnim; public Vector3 defaultPosition; void Update () { if (Input.GetAxis("Vertical") > 0.2) animation.CrossFade (walk.name); else animation.CrossFade (idle.name); if (Input.GetKey(KeyCode.RightShift)) { animation.CrossFade(runningAnim.name); this.transform.localRotation = Quaternion.Lerp(this.transform.localRotation, Quaternion.Euler(runningRot), lerpSpeed * Time.deltaTime); this.transform.localPosition = Vector3.Lerp(this.transform.localPosition, runningPos, lerpSpeed * Time.deltaTime); } else { this.transform.localPosition = Vector3.Lerp(this.transform.localPosition, defaultPosition, Time.deltaTime * lerpSpeed); } } } Thanks this is causing issue plz tell me about working script. Any help is appreciated here!
  2. [Photon] I coudn't see player.

    Hello! I`m back with another question regarding Photon. I made a multiplayer FPS game. All things are working good. Only problem is I can't see another player in JoinedRoom. You can see in screenshot: Next screenshot of fpsplayer and components attached to it. And server manager script and player manager script is as follow : using UnityEngine; using System.Collections; using UnityEngine.UI; public class PhotonManager : MonoBehaviour { GameObject spawn, cam; public Text connectText; public GameObject player; void Start (){ PhotonNetwork.ConnectUsingSettings("v1.0"); spawn = GameObject.Find("SpawnPoint"); cam = GameObject.Find("MatchCam"); } void OnJoinedLobby(){ Debug.Log("JoinedLobby!"); PhotonNetwork.JoinRandomRoom(); } void Update (){ connectText.text = PhotonNetwork.connectionStateDetailed.ToString (); } void OnPhotonRandomJoinFailed (){ Debug.Log("Failed to join Room!"); RoomOptions roomOptions = new RoomOptions (){ isVisible = true, maxPlayers = 8}; int randomNum = Random.Range(0, 1000000); PhotonNetwork.CreateRoom(randomNum.ToString(), roomOptions, TypedLobby.Default); } void OnJoinedRoom (){ Debug.Log("JoinedRoom!"); Spawn(); } void Spawn (){ GameObject myPlayer = PhotonNetwork.Instantiate(player.name, spawn.transform.position, spawn.transform.rotation, 0); myPlayer.transform.FindChild("PlayerRoot").gameObject.SetActive(true); myPlayer.GetComponent<MoveController>().enabled = true; myPlayer.GetComponent<MouseController>().enabled = true; cam.GetComponent<Camera>().enabled = false; } } using UnityEngine; using System.Collections; public class PlayerManager : Photon.MonoBehaviour { Vector3 realPosition; Quaternion realRotation; //public PhotonView photonView; void Update(){ if (photonView.isMine) { } else { transform.position = Vector3.Lerp (transform.position, realPosition, .1f); transform.rotation = Quaternion.Lerp (transform.rotation, realRotation, .1f); } } void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info){ if(stream.isWriting){ stream.SendNext(transform.position); stream.SendNext(transform.rotation); } else { realPosition = (Vector3)stream.ReceiveNext(); realRotation = (Quaternion)stream.ReceiveNext(); } //OBserver = Unreliable //Observe Compoennt = FpsPlayermanager drag into it } } Any help is appreciated here. Please help me! please!
  3. Need help with Tactical Shooter AI.

    I want to use the tactical shooter against my Player(FPSController), I had setup the scene with player and AI but it`s only shooting on me and can`t moving around so that whenever I go it follow me. I wanna make that when I shoot AI then it will take damage and when it shoot me it then I will take damage. My gun script and health script is taken from OneManArmy3d`s Au fps kit v1.5. If you want this package ask me I `ll give u. Please help me!
  4. Grunt1914

    Introduction I've decided to finally create a forum post for my game Grunt1914. I've been holding off for months because I dont feel like the game is quite ready for social media yet but I think I need to start putting it out there. We have been working on this game for about a year and a half now. Grunt1914 is a World War 1 themed multiplayer game set in various stages across the war torn world. It is based on the conflicts between the Allies and the Central Powers. You play as a foot-soldier fighting on a variety of maps from around the world at the time. You can play as an American, British, German or Ottoman soldier. You may use any weapon as any soldier meaning the weapons are not locked to their own countries's soldiers. Weapons are customizable in that you may add attachments to them in the load-out. Gameplay and content wise the experience will be somewhere between hardcore and casual. The game will be rather realistic but it wont be a "simulator". The game will have alternating weather and time of day for each round, which the match host can select. If you want to play in the snow at night time, that's up to you. If you want to play in the rain at daytime, you can. These factors will have an impact on game-play. Right now the game is using @themars2011's FPS MP kit for functionality but this is being heavily modified by one of our programmers. Content in the game Maps(Finished) Convoy The map is themed as a fueling and repairing location for war trains and vehicles in an undisclosed location in the North of America. The map features lots of cover in that it is littered with inactive or broken vehicles and trains. The map contains many vantage points and naturally thick vegetated areas. The map will feature sunny, snowy and rainy conditions for both daytime and night time. District The map is themed as a small untouched village in an undisclosed location in the West of Germany. The map features lots of cover in that it features many enter-able buildings, walls, and structures. The map has an outlay designed for close quarters combat but also features rooftops for longer ranged weaponry. The map will feature sunny, rainy and snowy conditions for both daytime and night time. Turmoil The map is themed as a war-torn homestead in an undisclosed location in the East of Germany. The map features lots of cover in the shape of terrain deformation due to bombings, encampments, hilltop bunkers, bombed houses and naturally thick vegetated areas. The map will feature sunny, snowy and rainy conditions for both daytime and night time. Solitude The map is themed as a royal cemetery in an undisclosed location in the North of Egypt. The map is very tight in terms of space and will require quick thinking to excel in. The map features lots of cover in the shape of graves, tombs, and tight angles. The map has many hidden spots so keep an eye on those pesky campers! The map will feature only clear conditions for both daytime and night time. Dugout The map is themed as a war-torn battlefield with debris scattered about in an undisclosed location in North-Eastern France. The map features countless war-torn burnt trees, logs and bushes that make for good cover. There are also underground dugouts containing ammunition and supplies for the battles that are held there. Among these there are also makeshift buildings such as bunkers. The map will feature sunny, rainy and snowy conditions for both daytime and night time. Maps(Unfinished) Passage Weapons The weapon list is a work in progress and will continually be updated. Rifles - Lee Enfield Mk I - Mauser K98 - Mauser M1916 - Lebel Model 1886 Semi-Automatics - MP40 - Sten MK5 - Thompson M1928A1 Automatics - M1918 Browning - MG 15 Shotguns - Remington M10 Pistols - Colt 1917 - Luger P08 Concept Art Here is some of the concept art that has been completed for Grunt1914. Maps Turmoil Convoy District Dugout Characters German infantry The game is continually being worked on and I will keep updating as progress is made. Follow the game Facebook Page Twitter and a website for the game will be online soon. There will also be a fundraiser at a later stage.
  5. Hello, I'm having a bit of a weird issue that I can't seem to solve. What I'm trying to do is animate my character, as a test I just want to animate the entire character (with root and everything) up and back down. However, when I set a keyframe and then add a second one, the first keyframe will now have the same value as the second keyframe. If I add a third keyframe the first and second keyframe will get the same value as third keyframe. Etc.. Why is this happening? I explained it visually here: My player has an animator controller. This happens for every bones/limb my character has, making it impossible to animate. I have some existing animations, but they don't have the proper XYZ movements of the root so I want to add them. I do seem te be able to animate an empty gameobject, but it doesn't work on my Player. My player: This is hope my player is built: Thanks in advance
  6. My player glitching on moving collider

    I ran into bug that i have no idea how to fix... The ship is moving up and down. My player is glitching through upper collider when it goes up as you see in this preview: https://gyazo.com/e57b5cc9007d619064a7c9b06d75c242 These are two colliders on my ship model. The bottom one is for buoyancy and the upper one is for player to walk on the ship. Could someone please help me? Thanks! https://gyazo.com/90a13dbf8e30b3d1fc299b87570f6f1e
  7. Player damage

    I need some help with player damage script. I use AU FPS kit and i would like to make so that zombie that i added does damage to player. Any ideas on how to do that?
  8. Hello everyone! My name it's LordZER0 and im here to tell something about me and what i will do and what i do.. So let's get started: Name: LordZER0 RealName: Gabriel Roberto Years: 12 Locate: Brazil, Rio de Janeiro Like: Games! What do: Post Videos on Youtube So, that's much it.. well if you guys want more of me, comment below! and check out my channel.. Right now i posted a Sniper Montage.. If you lucky you can get on my Video! Let me just say few things before i go play Thanks: You producters of the game did an awesome job! i love it so far so good! i hope there is much more updates do this game because i Love it! so thank you guys, and thanks for everyone for saying this amazing game that has created on the web.. See'ya!
  9. Here is a free autodesk page where you can generate a free character and customize it!! You only need an autodesk acount. Click here --> charactergenerator.autodesk.com
  10. Create Shadow of Player

    Hello Everybody I would like to know how to make a body shadow for a FPS. Thanks .
  11. Player Shadow

    I moved the question to http://armedunity.com/topic/11761-create-shadow-of-player/.
  12. Multiplayer User Manager Question

    Hello everybody, my question is : How I do a system to when any player join in the room(network), instantiate a UserManager which will contain him Kills/Deaths in the actual room, and when the player dies, this informations(kills/deaths) won't be lost? I'm using Unity 3D Networking, not Photon. Thanks
  13. Hey , I was going through some old scripts and I found this which I thought someone might use possibly so , here you go. *This script was not made by me it was only edited by me , its 2 scripts that I put together (both scripts are CCO so there is no infringement at least). var limitDiagonalSpeed = true; var toggleRun = false; var jumpSpeed = 8.0; var gravity = 20.0; var fallingDamageThreshold = 10.0; var slideWhenOverSlopeLimit = false; var slideOnTaggedObjects = false; var slideSpeed = 12.0; var airControl = false; var antiBumpFactor = .75; var antiBunnyHopFactor = 1; private var moveDirection = Vector3.zero; private var grounded = false; private var controller : CharacterController; private var myTransform : Transform; private var speed : float; private var hit : RaycastHit; private var fallStartLevel : float; private var falling = false; private var slideLimit : float; private var rayDistance : float; private var contactPoint : Vector3; private var playerControl = false; private var jumpTimer : int; var curStam : float = 100.0; var maxStam : float = 100.0; var isSprinting : boolean = false; var StaminaBarFG : Texture2D; var StaminaBarBG : Texture2D; var staminaBarLength : float; var percentOfStamina : float; var stamCooldown : boolean = false; function Start () { controller = GetComponent(CharacterController); myTransform = transform; speed = walkSpeed; rayDistance = controller.height * .5 + controller.radius; slideLimit = controller.slopeLimit - .1; jumpTimer = antiBunnyHopFactor; oldPos = transform.position; } function FixedUpdate() { var inputX = Input.GetAxis("Horizontal"); var inputY = Input.GetAxis("Vertical"); var inputModifyFactor = (inputX != 0.0 && inputY != 0.0 && limitDiagonalSpeed)? .7071 : 1.0; if (grounded) { var sliding = false; if (Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance)) { if (Vector3.Angle(hit.normal, Vector3.up) > slideLimit) sliding = true; } else { Physics.Raycast(contactPoint + Vector3.up, -Vector3.up, hit); if (Vector3.Angle(hit.normal, Vector3.up) > slideLimit) sliding = true; } if (falling) { falling = false; if (myTransform.position.y < fallStartLevel - fallingDamageThreshold) FallingDamageAlert (fallStartLevel - myTransform.position.y); } if (!toggleRun) speed = Input.GetButton("Run")? runSpeed : walkSpeed; if ( (sliding && slideWhenOverSlopeLimit) || (slideOnTaggedObjects && hit.collider.tag == "Slide") ) { var hitNormal = hit.normal; moveDirection = Vector3(hitNormal.x, -hitNormal.y, hitNormal.z); Vector3.OrthoNormalize (hitNormal, moveDirection); moveDirection *= slideSpeed; playerControl = false; } else { moveDirection = Vector3(inputX * inputModifyFactor, -antiBumpFactor, inputY * inputModifyFactor); moveDirection = myTransform.TransformDirection(moveDirection) * speed; playerControl = true; } if (!Input.GetButton("Jump")) jumpTimer++; else if (jumpTimer >= antiBunnyHopFactor) { moveDirection.y = jumpSpeed; jumpTimer = 0; } } else { if (!falling) { falling = true; fallStartLevel = myTransform.position.y; } if (airControl && playerControl) { moveDirection.x = inputX * speed * inputModifyFactor; moveDirection.z = inputY * speed * inputModifyFactor; moveDirection = myTransform.TransformDirection(moveDirection); } } moveDirection.y -= gravity * Time.deltaTime; grounded = (controller.Move(moveDirection * Time.deltaTime) & CollisionFlags.Below) != 0; } function Update () { if (toggleRun && grounded && Input.GetButtonDown("Run")) speed = (speed == walkSpeed? runSpeed : walkSpeed); percentOfStamina = curStam/maxStam; staminaBarLength = percentOfStamina*100; if(Input.GetKey("left shift") && curStam > 0 && stamCooldown == false ) { runSpeed = 20.0; isSprinting = true; } else { runSpeed = walkSpeed; isSprinting = false; } if(isSprinting == true && curStam >= 0) { curStam--; } if(isSprinting == false && curStam < 100.0) { curStam++; } if(curStam == 0) { stamCooldown = true; } if(curStam == 100.0) { stamCooldown = false; } } function OnControllerColliderHit (hit : ControllerColliderHit) { contactPoint = hit.point; } function FallingDamageAlert (fallDistance : float) { Debug.Log ("Ouch! Fell " + fallDistance + " units!"); } function OnGUI () { GUI.DrawTexture(Rect((Screen.width/2) - 100, 10, staminaBarLength * 2, 10), StaminaBarFG); GUI.DrawTexture(Rect((Screen.width/2) - 100, 10, 200, 10), StaminaBarBG); } @script RequireComponent(CharacterController)
  14. So here's the deal, basically in my game i'm having a huge open world and am having the player spawn at a random spawnPoint, in the open world. But the thing is is that i'm using GameObject.FindGameObjectsWithTag to find the spawn points (them i'm adding them in a array) I'm having my player instantiate at one of the spawn point in the array, only thing is I keep getting this message: NullReferenceException: Object reference not set to an instance of an object Spawn Manager.Spawn () (at Assets/Spawn Manager.js:16) Spawn Manager.Start () (at Assets/Spawn Manager.js:8) I checked within the code and am very confused, i'm sill learning this stuff and to the people who really know this, this question probably sounds stupid. But I still can't find the problem that Unity is talking about, I have a very short and simple script. Here it is: var spawnPoints : GameObject[]; // Array for Player's spawn var PlayerPrefab : GameObject; // Player Prefab to spawn function Start(){ spawnPoints = GameObject.FindGameObjectsWithTag("PlayerSpawn"); Spawn(); } function Spawn(){ var obj : GameObject = PlayerPrefab; var pos: GameObject = spawnPoints[Random.Range(0, spawnPoints.length)]; // Randomize Spawn Points Instantiate(obj, pos.position, pos.rotation); } See? Not much. The SpawnPoints I currently have in-game are tagged with "PlayerSpawn" but I know that's not the issue. And I'm sure i'm being just stupid with the issue here and i'm also sure that there's a easy way around this but that's why i'm asking for help, (So I can learn this stuff and get better) If anyone can help me figure this out much would be appreciated. Thanks!
  15. How to add custom player to the OMA kit ? Thanks! popolo.
  16. Hallo guys i am totaly new to javascript and C# but i tried making somefhing fast just to see what i have learned And so i think i should share it with you guys Player Script: static var MyHealth = 100; var MyDamage = 50; function Update () { if(MyHealth == 0) Die(); } function Die () { Destroy(this.gameObject); } function OnGUI () { GUILayout.Label("Health: " + MyHealth); } function OnTriggerEnter () { Debug.Log("KILLED ENEMY !!"); Enemy.EnemyHealth -= MyDamage; Enemy Script: #pragma strict static var EnemyHealth = 100; var EnemyDamage = 50; function Start () { } function Update () { if(EnemyHealth == 0) Destroy(this.gameObject); } function OnTriggerEnter() { damage.MyHealth -= EnemyDamage; } I know this is not the best but i tried :/
  17. Image video player

    Hey guys. I'm making kind of like a GIF image to make a cut scene. (I'm going to make a live action cut scene soon I know...... It's awesome) But I'm pretty sure that unity 3D doesn't support GIF's. So I was wondering if its possible to play the images in an order really fast? So it will be like a movie If someone could help that you be great. Thanks -Stuart
  18. How can I use Objectlabel script over network (I'm using FPS Multiplayer kit) ?? Objectlabel Script: http://wiki.unity3d.com/index.php?title=ObjectLabel
  19. Hey Guys I just wrote a new script for my player for my game but I have a problem I wrote the script in JavaScript and made a GUI.DrawTexture that the player can see his health but it wont work can anybody help me? Script: var currentGun : GameObject; var distToPickUpGun : float = 6; var throwGunUpForce : float = 100; var throwGunForwardForce : float = 300; var waitFrameForSwitchGuns : int = -1; var walkAcceleration : float = 5; var walkAccelAirRacio : float = 0.1; var walkDeacceleration : float = 5; @HideInInspector var walkDeaccelerationVolx : float; @HideInInspector var walkDeaccelerationVolz : float; var cameraObject : GameObject; var maxWalkSpeed : float = 20; @HideInInspector var horizontalMovement : Vector2; var jumpVelocity : float = 20; @HideInInspector var grounded : boolean = false; var maxSlope : float = 60; var crouchRacio : float = 0.3; var transitionToCrouchSec : float = 0.2; var crouchingVelocity : float; var currentCrouchRacio : float = 1; var originalLocalScaleY : float; var crouchLocalScaleY : float; var collisionDetectionSphere : GameObject; @HideInInspector var waitToPickupAmmo : float = 0; var currentCell : GameObject; var health : float = 3000; var deadBodyPrefab : GameObject; var BarLength : int = 100; var Texture2 : Texture2D; function Awake () { currentCrouchRacio = 1; originalLocalScaleY = transform.localScale.y; crouchLocalScaleY = transform.localScale.y * crouchRacio; } function LateUpdate () { if (grounded) rigidbody.useGravity = false; else rigidbody.useGravity = true; waitFrameForSwitchGuns -= 1; waitToPickupAmmo -= Time.deltaTime; transform.localScale.y = Mathf.Lerp(crouchLocalScaleY, originalLocalScaleY, currentCrouchRacio); if (Input.GetButton("Crouch")) currentCrouchRacio = Mathf.SmoothDamp(currentCrouchRacio, 0, crouchingVelocity, transitionToCrouchSec); if (Input.GetButton("Crouch") == false && collisionDetectionSphere.GetComponent(CollsionDetectionSphereScript).collisionDetected == false) currentCrouchRacio = Mathf.SmoothDamp(currentCrouchRacio, 1, crouchingVelocity, transitionToCrouchSec); horizontalMovement = Vector2(rigidbody.velocity.x, rigidbody.velocity.z); if (horizontalMovement.magnitude > maxWalkSpeed) { horizontalMovement = horizontalMovement.normalized; horizontalMovement *= maxWalkSpeed; } rigidbody.velocity.x = horizontalMovement.x; rigidbody.velocity.z = horizontalMovement.y; if (grounded){ rigidbody.velocity.x = Mathf.SmoothDamp(rigidbody.velocity.x, 0, walkDeaccelerationVolx, walkDeacceleration); rigidbody.velocity.z = Mathf.SmoothDamp(rigidbody.velocity.z, 0, walkDeaccelerationVolz, walkDeacceleration);} transform.rotation = Quaternion.Euler(0, cameraObject.GetComponent(MouseLookScript).currentYRotation, 0); /*if (grounded) rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration * Time.deltaTime, 0, Input.GetAxis("Vertical") * walkAcceleration * Time.deltaTime); else rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration * walkAccelAirRacio * Time.deltaTime, 0, Input.GetAxis("Vertical") * walkAcceleration * walkAccelAirRacio * Time.deltaTime); */ if (Input.GetButtonDown("Jump") && grounded) rigidbody.AddForce(0,jumpVelocity,0); if (health <= 0) { currentGun.GetComponent(GunScript).beingHeld = false; currentGun.rigidbody.AddRelativeForce(Vector3(0, throwGunUpForce, throwGunForwardForce)); Instantiate(deadBodyPrefab, transform.position, transform.rotation); collider.enabled = false; cameraObject.GetComponent(AudioListener).enabled = false; enabled = false; } } function FixedUpdate () { if (grounded) rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration, 0, Input.GetAxis("Vertical") * walkAcceleration); else rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration * walkAccelAirRacio, 0, Input.GetAxis("Vertical") * walkAcceleration * walkAccelAirRacio); } function OnCollisionStay (collision : Collision) { for (var contact : ContactPoint in collision.contacts) { if (Vector3.Angle(contact.normal, Vector3.up) < maxSlope) grounded = true; } } function OnCollisionExit () { grounded = false; } function OnTriggerExit () { currentCell = null; } function OnTriggerStay (hitTrigger : Collider) { if (hitTrigger.tag == "AIpathCell") currentCell = hitTrigger.gameObject; if (hitTrigger.transform.tag == "StairGoingUp") if (!Input.GetButton("Jump") && Vector3.Angle(rigidbody.velocity, hitTrigger.transform.forward) < 90) if (rigidbody.velocity.y > 0) rigidbody.velocity.y = 0; if (hitTrigger.transform.tag == "StairGoingDown") if (!Input.GetButton("Jump") && Vector3.Angle(rigidbody.velocity, hitTrigger.transform.forward) < 90) rigidbody.AddForce(0,-100,0); var current : GunScript = null; if (currentGun) current = currentGun.GetComponent(GunScript); var ammo : AmmoPickupScript = null; var gun : GunScript = null; if (hitTrigger.tag == "AmmoPickup" && waitToPickupAmmo <= 0) { ammo = hitTrigger.gameObject.GetComponent(AmmoPickupScript); if (current.currentExtraAmmo < current.maxExtraAmmo) { if (ammo.fromGun) { gun = ammo.gun.GetComponent(GunScript); if (gun.currentExtraAmmo > 0 && gun.ammoType == current.ammoType && ammo.gun != currentGun) { if (gun.currentExtraAmmo >= current.maxExtraAmmo - current.currentExtraAmmo) { gun.currentExtraAmmo -= current.maxExtraAmmo - current.currentExtraAmmo; current.currentExtraAmmo = current.maxExtraAmmo; } if (gun.currentExtraAmmo < current.maxExtraAmmo - current.currentExtraAmmo) { current.currentExtraAmmo += gun.currentExtraAmmo; gun.currentExtraAmmo = 0; } if (ammo.pickupSound) ammo.gameObject.GetComponent(AudioSource).Play(); } } if (!ammo.fromGun) { if (current.ammoType == ammo.ammoType || ammo.ammoType == -1) { if (ammo.ammoAmount > 0 && !ammo.unlimitedAmmo) { if (ammo.ammoAmount >= current.maxExtraAmmo - current.currentExtraAmmo) { ammo.ammoAmount -= current.maxExtraAmmo - current.currentExtraAmmo; current.currentExtraAmmo = current.maxExtraAmmo; } if (ammo.ammoAmount < current.maxExtraAmmo - current.currentExtraAmmo) { current.currentExtraAmmo += gun.currentExtraAmmo; ammo.ammoAmount = 0; } if (ammo.pickupSound) ammo.gameObject.GetComponent(AudioSource).Play(); } if (ammo.unlimitedAmmo) { current.currentExtraAmmo = current.maxExtraAmmo; if (ammo.pickupSound) ammo.gameObject.GetComponent(AudioSource).Play(); } } } } } } function OnGUI () { GUI.DrawTexture(Rect(400,430,100*health/BarLength,20),Texture2); }
  20. Simple teleport

    Hi, i helped couple people on unity answers, so i though I'd post it here. Maybe someone will find it useful, and if you aren't a good coder this will get you going. http://answers.unity3d.com/questions/514523/do-something-when-player-touches-gameobject.html Step 1. Create simple cube, and tag it "teleportPad". Place it somewhere on ground. Step 2. Create C# script called "Teleport", and paste in this code. You can translate it later in Unityscript. using UnityEngine; using System.Collections; public class Teleport : MonoBehaviour { public Transform destination; void OnControllerColliderHit(ControllerColliderHit col){ if(col.collider.gameObject.tag == "teleportPad"){ transform.position = destination.position; } } } Step 3. Save the script and attach it to player, (not camera). Step 4. Create new empty game object, place it somewhere 4 meters above the ground so you wouldn't fall through. Step 5. Drag and drop the created empty game object (created in step 4) onto "Destination", located in "Teleport" script on your player. Play it. When you will collide with the box you will be teleported to the empty game object position.
  21. hey Guys I just made a Script called "Hunger". (All two Scripts are JavaScripts) It is very simple and like a Hunger and health Bar with GUI Texture. If you add the Hunger Script to the Player there will stand nothing because you have to add a GUI Texture for the Hunger and the Health Bar. If the hunger is higher then 85 Points the player will be given 3 Live Points every Second. When the hunger is 0 your health will decrease by 3 every Second. here is the Script. Translations: Lebenstärke = Health Satt = Hunger Balkenlange = how longe the bar should be. Script: var Health : int = 100; var MaxHealth : int = 100; var Hunger : int = 100; var Timer : float; var Texture1 : Texture2D; var Texture2 : Texture2D; var BarLength : int = 100; private var Speed : int = 3; function Update () { Health = Mathf.Clamp(Health, 0, MaxHealth); if(Health > 0){ Timer += Time.deltaTime; if(Timer >= Speed) { if(Hunger >= 85) { Health += 3; } if(Hunger <= 0){ Health -= 1; Speed = 1; } else { ​ Hunger -= 1; Speed = 3; } Timer = 0; } } } function OnGUI () { GUI.DrawTexture(Rect(400,400,100*Hunger/BarLength,20),Texture1); GUI.DrawTexture(Rect(400,430,100*Health/BarLength,20),Texture2); }
  22. Single Player Login System

    Hello! I have coded a Login system in java. It is only Single Player, but it works well. Enjoy! var mySkin : GUISkin; var GeneralWidth = 73; // Width for most bottons should be the same. Use GeneralWidth. Use there custom Width if needed. var LoaderHeight = 10; var LoaderWidth = 10; var LogHeight = 101; var LogWidth = 163; var PlayerUsername = ""; var PlayerPassword = ""; var UserHeight = 35; var UserWidth = 1; var PassHeight = 65; var PassWidth = 1; var GameOwner = ""; var GameOwnerPassword = ""; var UsernameCORRECT = false; var PasswordCORRECT = false; var onSave : boolean = false; var Incorrect : boolean = false; var LogIn : boolean = false; var wrong : boolean = false; var waitTime : int = 3; function Start () { GameOwner = (PlayerPrefs.GetString("GameOwner")); GameOwnerPassword = (PlayerPrefs.GetString("GameOwnerPassword")); } function Update (){ // Updates each frames and checks if the TextArea is equal to the username we want if (PlayerUsername == GameOwner){ UsernameCORRECT = true; } else { UsernameCORRECT = false; } // Updates each frames and checks if the TextArea is equal to the password we want if (PlayerPassword == GameOwnerPassword){ PasswordCORRECT = true; } else { PasswordCORRECT = false; } if(onSave) { PlayerPrefs.SetString("GameOwner", GameOwner); PlayerPrefs.SetString("GameOwnerPassword", GameOwnerPassword); } } function OnGUI () { // Assign a skin to you menu GUI.skin = mySkin; // Background box GUI.Box (Rect (LoaderHeight,LoaderWidth,220,120), "Log-in"); //Text area for the username PlayerUsername = GUI.TextArea (Rect(GeneralWidth,UserHeight,100,20),PlayerUsername); //Text area for the password PlayerPassword = GUI.TextArea (Rect(GeneralWidth,PassHeight,100,20),PlayerPassword); // Loads level (0). This map can be set in the build settings if (GUI.Button (Rect (LogWidth,LogHeight,60,25), "Log-In")) { LogIn = true; if(UsernameCORRECT == true && PasswordCORRECT == true) { Application.LoadLevel(2); } else { Incorrect = true; wrong = true; } } if(GUI.Button (Rect (100,101,60,25), "Register")) { GameOwner = PlayerUsername; GameOwnerPassword = PlayerPassword; onSave = true; } if(Incorrect == true && LogIn == true) { if(wrong == true) { IncorrectGUI(); } } } function IncorrectGUI() { GUI.color = Color.red; GUI.Label (Rect (LogWidth,LogHeight + 30,200, 200), "Incorrect username or password"); yield WaitForSeconds(waitTime); wrong = false; } single_player_login.zip