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
    • Example Projects
    • Scripts
    • Shaders
    • Unity Tutorials
    • FPS Kit Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
    • 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


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

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL





YouTube URL

Facebook URL

Twitter URL

IndieGoGo URL

Kickstarter URL


GreenLight URL



Found 22 results

  1. Johannes


    A Throwback to the roots of classic first person shooting Think back to a time when military shooters were so dominant and important in your gaming schedule, what made them so good? It's simple, They were fun! No boats, tanks or jets to do your work for you - keep those boots on the ground! You are a soldier, you have your guns, your body and most vitally your mettle! Head out, Grunt! With a distinctly historical arsenal made available to you, you can choose to play any way you want. A selection of the weaponry also contains attachments that were either in use on the field or being tested at the time, giving you lots of options! Unlock more guns as you progress through the ranks to become the ultimate foot-soldier! Come sun, rain or snow in darkness or light, war will rage on! What's the forecast? You choose! You can play in clear, rainy or snowy settings in Grunt1914. These selections have a distinct effect on the maps you choose to fight on, as the visibility and controls adapt to the weather cycle at play! As the fog fills the air and the snow piles will you be able to hold your nerve and take that perfect shot? Time will tell! The Axis vs the Allies, blood will flow! It's the classic story as we've heard it told many times before, the story of brutality and fear, yet also victory and brave hearts! You can play as either a soldier from the Axis alignment, or the Allies confederation. Take up arms in Deathmatch, Team Deathmatch and Gun-Game modes as you rush to be proclaimed the victor above all others! Bordered arenas with tons of tricks and turns Do not desert the battle soldier! Grunt1914 features eight distinct and robust maps to explore and seek triumph in! These are all based on real life locations from novel and peculiar theaters of war of that historical time. Each map features certain unique traits and areas to uncover and unravel, as you make your way through deserts, forests, tombs, military bases, underground hospitals, towns and many more rare areas! Skill above all else There are no power-ups or buffs to help you here, no powers or special treatments to be had. Only one thing matters in Grunt1914, your tactics! How you react and the way you play will decide your fate! There are no vehicles or mounts to save you! Your skill is all you have here! Are you a sniper that favorites long range kills, are you a run and gun heavy grunt or are you sneaky silencer type? You can be any class you want, as long as you can survive! The nostalgia of a classic interface Brave the harsh battlefields and arenas with a compass and map in hand, use those senses to locate enemies on the field! All of these are neatly laid out and visible to you at all times, exactly when and where you will need them! Use these tools to your advantage to turn the tide and become the victor when all seems lost! About the developer Aligned Games© was started by me, Johannes Christiaan Nienaber in 2013 as a video-game development studio. At that time I focused on the creation of smaller scale games, but have since moved into developing bigger and better games. I run the studio myself and as such all of its associated video-game are my sole creations. Grunt1914 is my first foray into the PC gaming market. Please contact me through the studio's website if you have any queries or questions, you can do so at - https://alignedgames.com/ Other social links : Steam : https://store.steampowered.com/app/1059040 Discord : https://discord.gg/Tc5b7D9 Facebook : https://www.facebook.com/Grunt1914/ Twitter : https://twitter.com/grunt1914 IndieDB : https://www.indiedb.com/games/grunt1914 Youtube : https://www.youtube.com/channel/UCKfm34iEuHrFCduvV4OZpag Concept art : Screenshots :
  2. 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!
  3. 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!
  4. 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!
  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. 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. 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.
  8. 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?
  9. 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!
  10. 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
  11. Hello Everybody I would like to know how to make a body shadow for a FPS. Thanks .

    Player Shadow

    I moved the question to http://armedunity.com/topic/11761-create-shadow-of-player/.
  13. 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
  14. 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)
  15. 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!
  16. How to add custom player to the OMA kit ? Thanks! popolo.
  17. 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 :/
  18. 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); }
  19. Clunk

    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
  20. How can I use Objectlabel script over network (I'm using FPS Multiplayer kit) ?? Objectlabel Script: http://wiki.unity3d.com/index.php?title=ObjectLabel
  21. 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
  22. 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); }
  • Create New...