Quantcast
Channel: Questions in topic: "keyboard"
Viewing all articles
Browse latest Browse all 605

I need help with this script

$
0
0
Hello . I am new on Unity. I want to make a t$$anonymous$$rd game and downloaded on assest store about Basic Motions FREE and import on Unity. How can I Rotation with the keyboard the character on C# but it doesn't work. How can i solve that Problem ? using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerControl : MonoBehaviour { // Start is called before the first frame update private Rigidbody player; public float speed; public float jump; private bool isGrounded = true; public float gravityScale; void Start() { player = GetComponent(); } // Update is called once per frame void Update() { Vector3 dir = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); player.AddRelativeForce(dir * speed, ForceMode.Impulse); player.AddForce(Physics.gravity * (gravityScale - 1)* player.mass); player.velocity = Vector3.zero; if (Input.GetButtonDown("Jump")&& isGrounded) { player.AddForce(0, player.transform.position.y + jump, 0,ForceMode.Impulse); isGrounded = false; } } private void OnCollisionEnter(Collision collision) { if(collision.gameObject.tag == "Boden") { isGrounded = true; } } }

Viewing all articles
Browse latest Browse all 605

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>