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



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 114 results

  1. Third update with major improvements including sound, environment, speedometer, and more! This post includes screenshots and video. Enjoy! https://imgur.com/a/r9XJVjS
  2. Hi there, this is a fire light behaviour script I just made and I just wanted to share it It is not advanced, it is just lerping the position and the light's intensity to somewhat simulate a fire's light. Anyways, just attach the script to the fire's light, tweak the values and you're good to go Copy the below, then create a new C# script, and then paste the code in it(or write it all if ya want ). /* * Author: DeepWolf * Description: Simulates a light's behaviour of a fire. * * Usage: * Attach this script to the light source of the fire and tweak the values. */ namespace DeepWolf.Utilities { using UnityEngine; /// <summary> /// Represents a <see cref="FireLight"/>. /// Handles the breathing and the movement of the fire. /// </summary> [RequireComponent(typeof(Light))] public class FireLight : MonoBehaviour { /// <summary> /// How frequently the <see cref="FireLight"/> will find a new position. /// </summary> [Header("[Movement]")] [SerializeField, Tooltip("How frequenly the light will find a new position.")] private float moveFrequency = 0.15f; /// <summary> /// The lerp speed of the fire movement. The lower the speed, the smoother the movement will be. /// </summary> [SerializeField, Tooltip("The lerp speed of the fire movement. The lower the speed, the smoother the movement will be.")] private float moveLerpSpeed = 1.0f; /// <summary> /// The min and max value of how much the <see cref="FireLight"/>'s <see cref="Transform"/> is able to move in the x axis. /// </summary> [SerializeField, Tooltip("The min and max value of how much the light is able to move in the x axis.")] private Vector2 xMoveLimit = new Vector2(-0.2f, 0.2f); /// <summary> /// The min and max value of how much the <see cref="FireLight"/>'s <see cref="Transform"/> is able to move in the y axis. /// </summary> [SerializeField, Tooltip("The min and max value of how much the light is able to move in the y axis.")] private Vector2 yMoveLimit = new Vector2(-0.0f, 0.15f); /// <summary> /// The min and max value of how much the <see cref="Light"/>'s <see cref="Transform"/> is able to move in the z axis. /// </summary> [SerializeField, Tooltip("The min and max value of how much the light is able to move in the z axis.")] private Vector2 zMoveLimit = new Vector2(-0.2f, 0.2f); /// <summary> /// The breathing frequency of the <see cref="Light.intensity"/>. /// </summary> [Header("[Intensity Breathing]")] [SerializeField, Tooltip("The breathing frequency of the light's intensity.")] private float IntensityBreathFrequency = 0.5f; /// <summary> /// The speed of the intensity transition. /// </summary> [SerializeField, Tooltip("The speed of the intensity transition.")] private float intensityLerpSpeed = 2.0f; /// <summary> /// The minimum the <see cref="Light.intensity"/> value can be. /// </summary> [SerializeField, Tooltip("The minimum the light's intensity value can be.")] private float minIntensity = 0.5f; /// <summary> /// The maximum the <see cref="Light.intensity"/> value can be. /// </summary> [SerializeField, Tooltip("The maximum the light's intensity value can be.")] private float maxIntensity = 1.0f; /// <summary> /// The <see cref="Time.time"/> till the next move transition. /// </summary> private float nextMove; /// <summary> /// The <see cref="Time.time"/> till the next intensity transition. /// </summary> private float nextIntensity; /// <summary> /// The <see cref="Light.intensity"/> value to transition to. /// </summary> private float targetIntensity; /// <summary> /// The <see cref="Light.intensity"/> value to transition to. /// </summary> private Vector3 targetPosition; /// <summary> /// The original <see cref="FireLight"/> position. Used to offset the move limits from the orignal position when looking for a new position to transition to. /// </summary> private Vector3 originalPosition; /// <summary> /// The <see cref="Light"/> component on the <see cref="FireLight"/>. /// </summary> private new Light light; /// <summary> /// The <see cref="Transform"/> component on the <see cref="FireLight"/>. /// </summary> private new Transform transform; private void Awake() { light = GetComponent<Light>(); transform = GetComponent<Transform>(); originalPosition = transform.position; } private void Update() { HandleMovement(); HandleIntensityBreathing(); } /// <summary> /// Handles the movement transition to the <see cref="targetPosition"/>. /// </summary> private void HandleMovement() { // Move to target position transform.position = Vector3.Lerp(transform.position, targetPosition, moveLerpSpeed * Time.deltaTime); if (nextMove <= Time.time) { FindNewPosition(); nextMove = Time.time + moveFrequency; } } /// <summary> /// Finds a new <see cref="targetPosition"/> to transition to. /// </summary> private void FindNewPosition() { float newX = originalPosition.x + Random.Range(xMoveLimit.x, xMoveLimit.y); float newY = originalPosition.y + Random.Range(yMoveLimit.x, yMoveLimit.y); float newZ = originalPosition.z + Random.Range(zMoveLimit.x, zMoveLimit.y); // Find new position targetPosition.Set(newX, newY, newZ); } /// <summary> /// Handles the breathing of the <see cref="FireLight"/> by changing the <see cref="Light.intensity"/> smoothly to the <see cref="targetIntensity"/>. /// </summary> private void HandleIntensityBreathing() { light.intensity = Mathf.Lerp(light.intensity, targetIntensity, intensityLerpSpeed * Time.deltaTime); if (nextIntensity <= Time.time) { FindNewIntensity(); nextIntensity = Time.time + IntensityBreathFrequency; } } /// <summary> /// Finds a new <see cref="targetIntensity"/> to transition to. /// </summary> private void FindNewIntensity() { targetIntensity = Random.Range(minIntensity, maxIntensity); } } }
  3. Hi guys, here is a simple script for car control which contains Gears (5) No REAR Yet Stop Lights Start / Stop Engine Fuel System [Fuel consumption in relation with RPM] RPM Editable controls Simple attach the script into your can then attach the camera the sounds and the lights.. //Script By DarkStudio [NightBird] //Version 1.0.0.0 BETA using UnityEngine; using System.Collections; public class Player : MonoBehaviour { //Variables public Light LeftStop; // Left Stop Point Light public Light RightStop; // Reght Stop Point Light public Transform Car; // Your Car Model public Transform MyCamera; // Your Camera float movespeed = 0.0F; public float fuel = 1000.0F; int gas_pedal = 0; public int health = 100; // Not Used YET int rpm = 0; int gear = 1; bool isengine = false; public KeyCode addgas = KeyCode.W; public KeyCode removegas = KeyCode.S; public KeyCode clutchkey = KeyCode.Space; public KeyCode gearup = KeyCode.UpArrow; public KeyCode geardown = KeyCode.DownArrow; public KeyCode nogear = KeyCode.Alpha0; public KeyCode firstgear = KeyCode.Alpha1; public KeyCode seccondgear = KeyCode.Alpha2; public KeyCode thirdgear = KeyCode.Alpha3; public KeyCode fourthgear = KeyCode.Alpha4; public KeyCode fifthgear = KeyCode.Alpha5; public KeyCode reargear = KeyCode.Alpha9; public KeyCode startengine = KeyCode.E; public KeyCode ChangeCameraView = KeyCode.C; public KeyCode SteerLeft = KeyCode.A; public KeyCode SteerRight = KeyCode.D; public AudioClip EngineStart; public AudioClip EngineStop; public AudioClip IdleSound; public AudioClip GasPressed; public AudioClip BreakSound; void OnGUI() { GUI.Label(new Rect(5, 20, 100, 20), "RMP : " + rpm); GUI.Label(new Rect(5, 35, 100, 20), "Fuel : " + fuel); GUI.Label(new Rect(5, 50, 100, 20), "Gear : " + gear); GUI.Label(new Rect(5, 65, 100, 20), "Engine : " + isengine); } void Update() { if (fuel <= 0) { isengine = false; rpm = 0; } if (Input.GetKeyDown(startengine)) { if (isengine == false) { if (fuel >= 1.50F) { isengine = true; fuel -= 1.5F; rpm = 1000; AudioSource.PlayClipAtPoint(EngineStart, Car.position); Debug.Log("Engine ON"); } else { Debug.Log("Not Enough Fuel!"); } } else { isengine = false; rpm = 0; Debug.Log("Engine OFF"); AudioSource.PlayClipAtPoint(EngineStart, Car.position); } } if (isengine == true) { //Fuel System if (rpm <= 1000) { fuel -= 0.025F; } else if (rpm > 1000 && rpm <= 2500) { fuel -= 0.5F; } else if (rpm > 2500 && rpm <= 4000) { fuel -= 0.8F; } else if (rpm > 4000 && rpm <= 5000) { fuel -= 1.0F; } else if (rpm > 5000) { fuel -= 1.9F; } //End Fuel //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Steer Syste if (Input.GetKey(SteerLeft)) { if (movespeed <= 0) { } else { if (movespeed > 0F && movespeed <= 50F) { Car.transform.Rotate(Vector3.down, 2F); } else if (movespeed > 50F && movespeed < 90F) { Car.transform.Rotate(Vector3.down, 1.3F); } else if (movespeed > 90F) { Car.transform.Rotate(Vector3.down, 0.9F); } } } if (Input.GetKey(SteerRight)) { if (movespeed <= 0) { } else { if (movespeed > 0F && movespeed <= 50F) { Car.transform.Rotate(Vector3.up, 2F); } else if (movespeed > 50F && movespeed < 90F) { Car.transform.Rotate(Vector3.up, 1.3F); } else if (movespeed > 90F) { Car.transform.Rotate(Vector3.up, 0.9F); } } } //End Steer //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Gas System if (Input.GetKey(addgas)) { if (gas_pedal <= 100) { if (movespeed <= 0) { if (gear == 1) { Car.transform.Translate(Vector3.forward * Time.deltaTime * movespeed); gas_pedal += 1; Debug.Log("GAS PRESSED " + movespeed + " " + gas_pedal + " " + fuel); Debug.Log("GAS PRESSED " + movespeed + " " + gas_pedal + " " + gear + " " + rpm + " " + fuel); AudioSource.PlayClipAtPoint(GasPressed, Car.position); } else { isengine = false; AudioSource.PlayClipAtPoint(EngineStop, Car.position); } } else { Car.transform.Translate(Vector3.forward * Time.deltaTime * movespeed); gas_pedal += 1; Debug.Log("GAS PRESSED " + movespeed + " " + gas_pedal + " " + fuel); Debug.Log("GAS PRESSED " + movespeed + " " + gas_pedal + " " + gear + " " + rpm + " " + fuel); AudioSource.PlayClipAtPoint(GasPressed, Car.position); } } else { Car.transform.Translate(Vector3.forward * Time.deltaTime * movespeed); Debug.Log("GAS PRESSED " + movespeed + " " + gas_pedal + " " + gear + " " + rpm + " " + fuel); AudioSource.PlayClipAtPoint(GasPressed, Car.position); } } else { if (gas_pedal > 0) { Car.transform.Translate(Vector3.forward * Time.deltaTime * movespeed); gas_pedal -= 1; Debug.Log("GAS PRESSED " + movespeed + " " + gas_pedal + " " + gear + " " + rpm + " " + fuel); } } if (Input.GetKeyDown(firstgear)) { gear = 1; } else if (Input.GetKeyDown(seccondgear)) { gear = 2; } else if (Input.GetKeyDown(thirdgear)) { gear = 3; } else if (Input.GetKeyDown(fourthgear)) { gear = 4; } else if (Input.GetKeyDown(fifthgear)) { gear = 5; } else if (Input.GetKeyDown(nogear)) { gear = 0; } if (Input.GetKey(removegas)) { LeftStop.enabled = true; RightStop.enabled = true; if (gas_pedal > 0.0F) { gas_pedal -= 1; AudioSource.PlayClipAtPoint(BreakSound, Car.position); } } else { LeftStop.enabled = false; RightStop.enabled = false; } //End Gas //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //RMP System if (gas_pedal >= 10 && gas_pedal <= 20) { switch (gear) { case 0: rpm = 3000; movespeed = 0.0F; break; case 1: rpm = 1800; movespeed = 8.0F; break; case 2: rpm = 1500; movespeed = 12.0F; break; case 3: rpm = 1200; movespeed = 5.0F; break; case 4: rpm = 1100; movespeed = 3.0F; break; case 5: rpm = 800; movespeed = 0.3F; break; case 9: rpm = 1700; movespeed = -9.0F; break; } } else if (gas_pedal < 10) { switch (gear) { case 0: rpm = 2000; movespeed = 0.0F; break; case 1: rpm = 1200; movespeed = 8.0F; break; case 2: rpm = 1000; movespeed = 12.0F; break; case 3: rpm = 800; movespeed = 5.0F; break; case 4: rpm = 400; movespeed = 3.0F; break; case 5: rpm = 200; movespeed = 0.3F; break; case 9: rpm = 1200; movespeed = -9.0F; break; } } else if (gas_pedal > 20 && gas_pedal <= 40) { switch (gear) { case 0: rpm = 5000; movespeed = 0.0F; break; case 1: rpm = 2800; movespeed = 14.0F; break; case 2: rpm = 2300; movespeed = 17.0F; break; case 3: rpm = 1800; movespeed = 24.0F; break; case 4: rpm = 1600; movespeed = 20.0F; break; case 5: rpm = 1200; movespeed = 15.0F; break; case 9: rpm = 2200; movespeed = -15.0F; break; } } else if (gas_pedal > 40 && gas_pedal <= 60) { switch (gear) { case 0: rpm = 7000; movespeed = 0.0F; break; case 1: rpm = 4500; movespeed = 18.0F; break; case 2: rpm = 2900; movespeed = 25.0F; break; case 3: rpm = 2400; movespeed = 35.0F; break; case 4: rpm = 2000; movespeed = 46.0F; break; case 5: rpm = 1700; movespeed = 56.0F; break; case 9: rpm = 4500; movespeed = -30.0F; break; } } else if (gas_pedal > 60 && gas_pedal <= 80) { switch (gear) { case 0: rpm = 9000; movespeed = 0.0F; break; case 1: rpm = 6500; movespeed = 24.0F; break; case 2: rpm = 4500; movespeed = 38.0F; break; case 3: rpm = 4000; movespeed = 75.0F; break; case 4: rpm = 3600; movespeed = 95.0F; break; case 5: rpm = 3000; movespeed = 120.0F; break; case 9: rpm = 4800; movespeed = -35.0F; break; } } else if (gas_pedal > 80 && gas_pedal <= 90) { switch (gear) { case 0: rpm = 14000; movespeed = 0.0F; break; case 1: rpm = 8700; movespeed = 32.0F; break; case 2: rpm = 7800; movespeed = 50.0F; break; case 3: rpm = 6700; movespeed = 106.0F; break; case 4: rpm = 4200; movespeed = 120.0F; break; case 5: rpm = 3800; movespeed = 140.0F; break; case 9: rpm = 5200; movespeed = -48.0F; break; } } else if (gas_pedal > 90 && gas_pedal <= 100) { switch (gear) { case 0: rpm = 17000; movespeed = 0.0F; break; case 1: rpm = 12700; movespeed = 42.0F; break; case 2: rpm = 8500; movespeed = 60.0F; break; case 3: rpm = 7400; movespeed = 126.0F; break; case 4: rpm = 5700; movespeed = 140.0F; break; case 5: rpm = 5200; movespeed = 180.0F; break; case 9: rpm = 8400; movespeed = -68.0F; break; } } //End RMP //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // AudioSource.PlayClipAtPoint(IdleSound, Car.position); } else { if (Input.GetKey(SteerLeft)) { if (movespeed <= 0) { } else { Car.transform.Rotate(Vector3.down, 0.4F); } } if (Input.GetKey(SteerRight)) { if (movespeed <= 0) { } else { Car.transform.Rotate(Vector3.up, 0.4F); } } LeftStop.enabled = false; RightStop.enabled = false; if (movespeed > 0) { if (!isengine) { Car.transform.Translate(Vector3.forward * Time.deltaTime * movespeed); movespeed -= 1.0F; Debug.Log("GAS PRESSED " + movespeed + " " + gas_pedal + " " + gear + " " + rpm + " " + fuel); } } } } }
  4. var zoom : int = 20; //determines amount of zoom capable. Larger number means further zoomed in var normal : int = 60; //determines the default view of the camera when not zoomed in var smooth : float = 5; //smooth determines speed of transition between zoomed in and default state private var zoomedIn = false; //boolean that determines whether we are in zoomed in state or not function Update () { if(Input.GetKeyDown("z")){ //This function toggles zoom capabilities with the Z key. If it's zoomed in, it will zoom out zoomedIn = !zoomedIn; } if(zoomedIn == true){ //If "zoomedIn" is true, then it will not zoom in, but if it's false (not zoomed in) then it will zoom in. camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,zoom,Time.deltaTime*smooth); } else{ camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,normal,Time.deltaTime*smooth); } } This is my zoom effect made in JavaScript. Hope you like it PS: you have to put the script on the camera.
  5. So, you may have seen my crappy fps before, but now I made an even better one! I deleted a whole bunch of random things on my drive to make space, and that old fps was one of them. Not much to look at for right now, I have been trying to get the basics down. There is crouching, better jumping, good footstep sounds, fully working AKM, attachment system ( I don't have any models yet), etc. So here are some screenshots! Probably going to replace the arms, and there is no Post-Processing yet. I don't know how to work blender to well, but the arms are mine! Still, I think it looks ok so far
  6. Hello! This is my first post ever! I just wanted to share a simple gun script that uses C#. Probably the best script for beginners! There are two scripts, one for the gun, and one for the enemies to shoot at! Hope u like it! 1st script: using UnityEngine; public class Gun : MonoBehaviour { public float damage = 25f; public float range = 100f; public Camera fpsCam; public ParticleSystem muzzleFlash; // Update is called once per frame void Update () { if (Input.GetButtonDown("Fire1")) { Shoot(); } } void Shoot () { muzzleFlash.Play(); RaycastHit hit; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range)) { Debug.Log(hit.transform.name); Target target = hit.transform.GetComponent<Target>(); if (target != null) { target.TakeDamage(damage); } } } } 2nd Script (Target Script) using UnityEngine; public class Target : MonoBehaviour { public float health = 50f; //what makes the damage work public void TakeDamage (float amount) { health -= amount; if (health <= 0f) { Die(); } } void Die () { Destroy(gameObject); } } There u go! those are all of the scripts! (Credit to brackeys for them.)
  7. Hello guys! I am beginner to Unity3D and I am building a 3D FPS Multiplayer Game! My problem is... I want to create a shop that player can buy weapons! But next time that he plays the game weapon is gone! SO, HOW CAN I SAVE A PURCHASED WEAPON (i would prefer to tell me via PlayerPrefs) THANK YOU!
  8. Hi! While developing on a game of mine, I decided to make a few changes to the camera. I got some inspiration from the camera in Running With Rifles and I really liked it, so I decided to make it like that. Here's a little video of it in action, in my game: Setting it up: Create an empty gameobject, and name it something like Camera Pivot. This is the gameobject that will be moved. Create a camera gameobject, and attach it to the Camera Pivot gameobject Offset the camera gameobject so it points downward, and is a bit in the air Attach the script to the Camera Pivot gameobject. Configure the settings to your likings, and everything should work. If you have any problems, I'll try to help. Script:
  9. hello, i am new here. i am trying to build a small unity 2d game. on starting my car will in running and on getting input it will be run right like circle movement. i am stuck how to rotate my car to getting input. thank.
  10. I need a tutorial or script to make the move to "walk" the gun. And in that same Script, I want to make a transition from "walk" to "run" when the "Shift" button is selected and the "walk" will normally walk with the "W" key. (Is there any possibility of doing this in an "animation" without using "animator"?) ----------------- I have a script, but I need a new one. In what I have this giving incompatibilities and when I go to pushing the key to "run", it practically goes without any smoothing, it is as if the animation was totally cut and started from a different point. My script : using UnityEngine; using System.Collections; public class moveAnim : MonoBehaviour { public Rigidbody rb; public Animation anim; public AnimationClip walk; public AnimationClip idle; public AnimationClip reload; public AnimationClip walkingReload; public AnimationClip sprint; public AnimationClip crouch; public AnimationClip crouchWalk; float sprintMult = 1; public bool pauseWalkOnAim = true; void Awake() { if(rb.GetComponent<characterControls>() != null) { sprintMult = rb.GetComponent<characterControls>().sprintMultiplier; } } void FixedUpdate() { characterControls cc = rb.GetComponent<characterControls>(); if (crouch != null) { if (cc.body.height == cc.normalHeight) { if (reload != null) { if (!anim.IsPlaying(reload.name) && !anim.IsPlaying(walkingReload.name)) { if (rb.velocity.magnitude >= 0.1f) { float sprintSpeed = rb.GetComponent<characterControls>().speed * sprintMult; if (rb.GetComponent<characterControls>().curSpeed < sprintSpeed) { if (pauseWalkOnAim) { if (!Input.GetMouseButton(1)) {a anim.CrossFade(walk.name); } } else { anim.CrossFade(walk.name); } } else { if (sprint != null) { anim.CrossFade(sprint.name); } } } else { anim.CrossFade(idle.name); } } else { if (reload != null) { if (anim.IsPlaying(reload.name) && rb.velocity.magnitude > 0.1f) { anim.CrossFade(walkingReload.name); } if (anim.IsPlaying(walkingReload.name) && rb.velocity.magnitude == 0) { anim.CrossFade(reload.name); } } } } else { if (rb.velocity.magnitude > 0.1f) { if (Input.GetKey(KeyCode.LeftShift)) { anim.CrossFade(sprint.name); } else { if (pauseWalkOnAim) { if (!Input.GetMouseButton(1)) { anim.CrossFade(walk.name); } } else { anim.CrossFade(walk.name); } } } else { anim.CrossFade(idle.name); } } } else { if (rb.velocity.magnitude <= 0.1f) { anim.CrossFade(crouch.name); } else { anim.CrossFade(crouchWalk.name); } } } else { if (reload != null) { if (!anim.IsPlaying(reload.name) && !anim.IsPlaying(walkingReload.name)) { if (rb.velocity.magnitude >= 0.1f) { float sprintSpeed = rb.GetComponent<characterControls>().speed * sprintMult; if (rb.GetComponent<characterControls>().curSpeed < sprintSpeed) { if (pauseWalkOnAim) { if (!Input.GetMouseButton(1)) { anim.CrossFade(walk.name); } } else { anim.CrossFade(walk.name); } } else { if (sprint != null) { anim.CrossFade(sprint.name); } } } else { anim.CrossFade(idle.name); } } else { if (reload != null) { if (anim.IsPlaying(reload.name) && rb.velocity.magnitude > 0.1f) { anim.CrossFade(walkingReload.name); } if (anim.IsPlaying(walkingReload.name) && rb.velocity.magnitude == 0) { anim.CrossFade(reload.name); } } } } else { if (rb.velocity.magnitude > 0.1f) { if (Input.GetKey(KeyCode.LeftShift)) { anim.CrossFade(sprint.name); } else { if (pauseWalkOnAim) { if (!Input.GetMouseButton(1)) { anim.CrossFade(walk.name); } } else { anim.CrossFade(walk.name); } } } else { anim.CrossFade(idle.name); } } } if(pauseWalkOnAim) { if (Input.GetKeyUp(KeyCode.LeftShift)) { if (rb.velocity.magnitude > 0) { anim.CrossFade(walk.name); } else { anim.CrossFade(idle.name); } } } anim[walk.name].speed = rb.velocity.magnitude / rb.GetComponent<characterControls>().speed; } }
  11. Hello, I am learning C# and beside I am also creating my own FPS game. Here is gun idle (sway) script I have taken this line from a script now I got stuck in it. The problem is I want remove following things so that it can work fully. Onemanarmy had said that learn scripting by yourself and yes i am learning but I need help here. I want to change this keywords to some other words so that it can work fully following words are: Yes I also want to remove if(weapon.isSelect){ Here is full code. public float smooth = 4.0f; // Speed to stabilize the movement. public float tiltAngle = 5.0f; // Average angle that the gun can tilt. public float maxTiltAngle = 15; // Maximum angle that the gun can tilt. public Transform tiltTarget; private void Update () { if (weapon.isSelected) { // If the player is not stopped or you are moving the mouse. if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0 || weapon.controller.GetInput() != Vector2.zero) { // Tilt in Y. float TiltY = Mathf.Clamp(Input.GetAxis("Mouse X") * -tiltAngle, -maxTiltAngle, maxTiltAngle); // Tilt in X. float TiltX = Mathf.Clamp(Input.GetAxis("Mouse Y") * tiltAngle, -maxTiltAngle, maxTiltAngle); // Tilt in Z. float TiltZ = weapon.controller.GetComponent<Rigidbody>().velocity.magnitude >= weapon.controller.crouchSpeed * 0.8f ? Mathf.Clamp(weapon.controller.GetInput().x * -tiltAngle, -maxTiltAngle, maxTiltAngle) : 0; // Defines the end position according to the tilt on each axis. Quaternion newRotation = Quaternion.Euler(TiltX, TiltY, TiltZ); // Moves the weapon from the current rotation to the end rotation. tiltTarget.localRotation = Quaternion.Lerp(tiltTarget.localRotation, newRotation, Time.deltaTime * smooth); } else { // If the player is not moving and the mouse input is zero (Vector2.zero), reset it to its original position. tiltTarget.localRotation = Quaternion.Lerp(tiltTarget.localRotation, Quaternion.identity, Time.deltaTime * smooth); } } else { // If the player is not moving and the mouse input is zero (Vector2.zero), reset it to its original position. tiltTarget.localRotation = Quaternion.Lerp(tiltTarget.localRotation, Quaternion.identity, Time.deltaTime * smooth); } } I have taken this from FPSE(I spent $35 for this plz help) I hope u people understand and will help me plz plz plz plz.
  12. so i have made this script and whenever i use it, it freezes my unity and i cant use unity so i have to restart my computer, help please try the script your self on a gun; its a gun script using UnityEngine; using UnityEngine.UI; using System.Collections; public class Gun2 : MonoBehaviour { [Header("Gun Data")] public float damage = 10f; public float range = 100f; public float impactForce = 30f; public float fireRate = 15f; public float shootTime = 0.1f; public float ShootDelay = 0.01f; public float ShootAnimTime; public float AcuracyReturn; public GameObject Muzzle; public Transform MuzzleReset; [Space] [Header("Ammo & Reloading")] public int AmmoInClip; public int AmmoClips; public int MaxAmmo; public bool OutOfAmmo; [Space] public float reloadTime; [Space] [Header("Scoping")] public float scopedFOV; public float normalFOV; [Space] [Header("Gun Objects")] public Text AmmoText; public GameObject NoAmmoText; [Space] public ParticleSystem muzzleflash; public GameObject impactEffect; [Space] public GameObject Hitmarker; public float HitmarkerTimeOnScreen; [Space] [Header("Animator")] public Animator _Animator; private bool isScoped; [Space] [Header("GunSounds")] public AudioSource _AudioSource; public AudioClip ShootSound; public AudioClip OutOfAmmoShoot; public AudioClip SuppressedFireSound; public AudioClip ReloadSound; [Space] [Header("Other")] public Camera fpsCam; public bool isReloading; void Start() { Muzzle.transform.Rotate(0f, 0f, 0f); _Animator.SetBool("Idle", true); NoAmmoText.SetActive(false); } void OnEnable() { isReloading = false; _Animator.SetBool("Reloading", false); _Animator.SetBool("AimToIdle", true); _Animator.SetBool("Idle", true); } // Update is called once per frame void Update() { AmmoText.text = "Ammo: " + AmmoInClip + " /" + " Clips: " + AmmoClips; if (AmmoClips <= 0) { if (Input.GetKeyDown("r")) { return; } } if (Input.GetKey(KeyCode.W)) { if (Input.GetKey(KeyCode.LeftShift)) { _Animator.SetBool("Running", true); if (Input.GetKeyDown("r")) { return; } if (Input.GetButton("Fire1") && Time.time >= ShootDelay) { return; } if (Input.GetButton("Fire2")) { return; } } } if (Input.GetKeyUp(KeyCode.LeftShift)) { _Animator.SetBool("Running", false); } if (isReloading) { if (Input.GetKey(KeyCode.LeftShift)) { _Animator.SetBool("Running", false); } } if (Input.GetButton("Fire2")) { isScoped = true; _Animator.SetBool("Aiming", true); } if (Input.GetButtonUp("Fire2")) { isScoped = false; fpsCam.fieldOfView = normalFOV; _Animator.SetBool("Aiming", false); } if (AmmoClips <= 0 && AmmoInClip <= 0) { NoAmmo(); return; } if (isReloading) return; if (AmmoInClip <= 0) { StartCoroutine(Reload()); return; } if (Input.GetKeyDown("r")) { StartCoroutine(Reload()); _Animator.SetBool("Aiming", false); return; } if (Input.GetButton("Fire1") && Time.time >= ShootDelay) { ShootDelay = Time.time + 1f / fireRate; StartCoroutine(Shoot()); } } //Reloading Mechanics IEnumerator Reload() { isReloading = true; Debug.Log("Reloading..."); _AudioSource.PlayOneShot(ReloadSound); _Animator.SetBool("Reloading", true); yield return new WaitForSeconds(reloadTime); _Animator.SetBool("Reloading", false); AmmoClips -= 1; AmmoInClip = MaxAmmo; isReloading = false; } //Shooting Mechanics IEnumerator Shoot() { _Animator.SetBool("Shooting", true); muzzleflash.Play(); AmmoInClip--; RaycastHit hit; if (Physics.Raycast(Muzzle.transform.position, Muzzle.transform.forward, out hit, range)) { Debug.Log(hit.transform.name); Target target = hit.transform.GetComponent<Target>(); if (target != null) { target.TakeDamage(damage); Hitmarker.SetActive(true); yield return new WaitForSeconds(HitmarkerTimeOnScreen); Hitmarker.SetActive(false); } if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * impactForce); } GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(impactGO, 1f); } Muzzle.transform.Rotate(0.3f, 0f, 0f); if (Input.GetButton("Fire1")) { StartCoroutine(Shoot()); } else yield return new WaitForSeconds(AcuracyReturn); Muzzle.transform.Rotate(-0.3f, 0f, 0f); } void NoAmmo() { OutOfAmmo = true; NoAmmoText.SetActive(true); } }
  13. I am trying to do a DOOM style FPS but I am stuck at the animation... In addition to my problems my GetButtonDown (left mouse click) is not working public Sprite idlePistol; public Sprite shotPistol; public float pistolDamage; public float pistolRange; public AudioClip shotSound; AudioSource source; void Awake() { source = GetComponent<AudioSource>(); } void FixedUpdate() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if(Input.GetButtonDown("Fire1")) { source.PlayOneShot(shotSound); StartCoroutine("shot"); if(Physics.Raycast(ray, out hit, pistolRange)) { Debug.Log("Wszedlem w kolizje z " + hit.collider.gameObject.name); hit.collider.gameObject.SendMessage("pistolHit", pistolDamage, SendMessageOptions.DontRequireReceiver); } } } IEnumerator shot() { GetComponent<SpriteRenderer>().sprite = shotPistol; yield return new WaitForSeconds(0.1f); GetComponent<SpriteRenderer>().sprite = idlePistol; } }
  14. Hey guys. So it's been a while since I last released a script, so here's a very simplistic and compact, yet effective weapon sway script I wrote up in C#. It's by far the shortest weapon sway script I've seen on the internet (and written for that matter). It's quite different from other sway scripts in terms of the effect. It has my own little taste added to it. Just drag the script on to your weapon and you're all set. If the weapon flips, reset your axes. Enjoy!
  15. Hi everyone i have problem with this Script its not working with unity5 and give me Error please fix the script for me thanks sorry for my English var HipPose : Vector3; var AimPose : Vector3; var AimSpeed = 15; private var MainCam : GameObject; private var WeapCam : GameObject; function Start () { transform.localPosition = HipPose; MainCam = GameObject.FindGameObjectWithTag("MainCamera"); WeapCam = GameObject.FindGameObjectWithTag("WeaponCamera"); } function Update () { if(Input.GetButton("Fire2")) { MainCam.camera.fieldOfView = 50; // transform.localPosition = AimPose; transform.localPosition = Vector3.Lerp(transform.localPosition,AimPose,AimSpeed*Time.deltaTime); } if(!Input.GetButton("Fire2")) { // transform.localPosition = HipPose; MainCam.camera.fieldOfView = 60; transform.localPosition = Vector3.Lerp(transform.localPosition,HipPose,AimSpeed*Time.deltaTime); } }
  16. So im going to summarize what i need help with. I am trying to copy a kill streak from Call of Duty "The Mortar Strike" but with changes. i Want the player to go to a station and spend theyre In-Game points they have earned (from kills and other tasks) to be able to use this kill streak. and instead of a mortar strike. It will be artillery strike from the battleships in the distance. I would like to see someone write the script for me, but that takes time out of peoples lives, so Id like to learn if if possible. I was hoping if someone can show me a video tutorial of someone making a script for this situation :/ that would really help
  17. It was a cool script that I made, hope you like it! http://www.mediafire.com/file/6vwa6q33c3fxi3q/blockPlacerAsset.unitypackage
  18. |Cinematic Camera Shake| -Description: This is a perfect script if you are making a cutscene and you want to add a bit of "spice" , this will make your camera shake , you can modify it to make it fit in your cinematic. This can also be useful for earthquakes with the correct settings. -Useful Level : 7/10 (only useful for cinematics/cutscenes) --Script: using UnityEngine; using System.Collections; class Noise { Vector2 seed; float speed; public Noise(float speed) { this.seed = new Vector2(Random.value, Random.value); this.speed = speed; } public float Update() { seed += Vector2.one * speed * Time.deltaTime; return Mathf.PerlinNoise(seed.x, seed.y) * 2 - 1; } } public class CameraShake : MonoBehaviour { Transform myTransform; Vector3 initPos; public float bigRadius = 3.0f; public float bigSpeed = 0.5f; public float smallRadius = 0.5f; public float smallSpeed = 2.0f; Noise noiseBigX; Noise noiseBigY; Noise noiseSmallX; Noise noiseSmallY; void Start() { myTransform = this.transform; initPos = myTransform.position; noiseBigX = new Noise(bigSpeed); noiseBigY = new Noise(bigSpeed); noiseSmallX = new Noise(smallSpeed); noiseSmallY = new Noise(smallSpeed); } void Update() { myTransform.position = initPos + new Vector3(noiseBigX.Update() * bigRadius + noiseSmallX.Update() * smallRadius, noiseBigY.Update() * bigRadius + noiseSmallY.Update() * smallRadius, 0); } }
  19. Javascript: function PlayGame() { Application.LoadLevel(1); } function QuitGame() { Application.Quit(); } Setup: 1.Make an empty gameobject and apply the script to the game object. 2.Go to your button and press the plus button By the "On Click" Box. 3.Drag your game object where it needs to be. 4.Now select "PlayGame" or "QuitGame" Note: You need to build both levels otherwise it wont work.Make sure That the main menu is "Scene 0"
  20. I REALLY need a script for swimming. I already have USA's(Unity Standard Assets) water prefab. I need only the script. Thanks in advance
  21. Hi everyone, I'm wanted to make a FPS survival game which had: - Crafting system. - Melee weapons. - Bow and arrow. Note: All i need just crafting melee and using it, as well as bow and arrow. p/s: i can design 2D textures for GUI and UI for any requests. Cheers
  22. This script will let you switch scenes by pressing on a Collider. Download How to use. ------------ 1. Make a GameObject in your scene. 2. Create a Collider on that GameObject. 3. Make sure that the GameObject is on the Camera. 4. Copy the Menu Script on the GameObject. 5. Save the Scene and create a new Scene. 6. Save both Scenes give it a name. 7. Add the both Scenes to the Build. 8. Go to the first scene where you created the GameObject and select the GameObject. 9. When selected go to the Inpector and you can write the other scene name you want to load. 10. THAT'S IT!! ------------
  23. How To Fix This? Error: Assets/MultiPlayer/Scripts/Menus/ConnectMenu.cs(188,41): error CS0117: `UnityEngine.SceneManagement.SceneManager' does not contain a definition for `GetActiveScene' Script:
  24. Hi guys, fisrt of all, i have to say that i am learning C# so please dont be mean D: I was searching for a C# script to show an image while you are on a trigger. I have searched, but i only find JS tutorials. Please help
  25. Hi guys. I need some help with the "FPSKitV1.2" It wont let me pick up weapons , and hit/shot things. Im not the best at english but im Danish so i understand but i dont know some words
×
×
  • Create New...