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.

Aga

Newbie
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Aga

  • Rank
    Newbie
  • Birthday 02/23/1999

Profile Information

  • Gender
    Male
  • Location:
    Earth
  • Interests
    Games

Contact Methods

  • Skype
    andyboos2
  1. I was on my phone and i couldn't watch the video. Now i've seen it and understood everything i needed to know. Thanks, i like the new Unity logo now.
  2. I heard that this is available for the Personal Edition aswell but there are some restrictions, is it true?
  3. Aga

    Terrain collider

    Save the scene before testing.
  4. using UnityEngine; using System.Collections; public class PlayerMovement : MonoBehaviour { public float walkSpeed = 5F; public float speed = 6.0F; public float jumpSpeed = 8.0F; public float gravity = 20.0F; public float crouchSpeed = 3F; public Transform Player; Vector3 direction = Vector3.zero; CharacterController charController; private float charHeight; private Vector3 pos; private Vector3 moveDirection = Vector3.zero; void Start () { Player=transform; charController= GetComponent<CharacterController>(); charHeight=charController.height; } // Update is called once per frame void Update () { if (Input.GetKey (KeyCode.W)) // Move forward transform.Translate (Vector3.forward * walkSpeed * Time.deltaTime); if (Input.GetKey (KeyCode.S)) // Move back transform.Translate (Vector3.back * walkSpeed * Time.deltaTime); if (Input.GetKey (KeyCode.A)) // Move left transform.Translate (Vector3.left * walkSpeed * Time.deltaTime); if (Input.GetKey (KeyCode.D)) // Move Right transform.Translate (Vector3.right * walkSpeed * Time.deltaTime); if(direction.magnitude > 1f) { direction = direction.normalized; } CharacterController controller = GetComponent<CharacterController>(); if (controller.isGrounded) { moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed; if (Input.GetButton("Jump")) moveDirection.y = jumpSpeed; } moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); float h = charHeight; if(Input.GetKey(KeyCode.C)){ h=1; } float lastHeight = charController.height; charController.height = Mathf.Lerp(charController.height, h, Time.deltaTime*5); pos.x=Player.position.x; pos.z= Player.position.z; pos.y = Player.position.y +(charController.height-lastHeight)/2; Player.position = pos; } } I added a crouch script.
  5. Add the jump script under this: if(direction.magnitude > 1f) { direction = direction.normalized; }
  6. CharacterController controller = GetComponent<CharacterController>(); if (controller.isGrounded) { moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed; if (Input.GetButton("Jump")) moveDirection.y = jumpSpeed; } moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime);
  7. using UnityEngine; using System.Collections; public class Movement : MonoBehaviour { public float walkSpeed = 10f; Vector3 direction = Vector3.zero; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(Input.GetKey (KeyCode.Z)) transform.Translate(Vector3.forward * walkSpeed * Time.deltaTime); if(Input.GetKey (KeyCode.S)) transform.Translate(Vector3.back * walkSpeed * Time.deltaTime); if(Input.GetKey (KeyCode.Q)) transform.Translate(Vector3.left * walkSpeed * Time.deltaTime); if(Input.GetKey (KeyCode.D)) transform.Translate(Vector3.right * walkSpeed * Time.deltaTime); if(direction.magnitude > 1f) { direction = direction.normalized; } } }
×
×
  • Create New...