player Gravity haw to Roted?
i have sprite for Gravity who works bat player is not Roted with Gravity if you know that https://www.youtube.com/watch?v=qdFuPWC1cGA&list=PLMhGTQfWN-kT9urtOnP3-Kde2i9wNpvBQ
Comment
Gravity js script
pragma strict
var baritita : float;
var x : float;
var y : float; var z : float;
function OnTriggerStay (other : Collider) { if (other.attachedRigidbody) other.attachedRigidbody.AddForce(Vector3(x, y, z) * baritita); }
Best Answer
Answer by watercat · Dec 15, 2017 at 12:12 PM
PlayerController C#
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float moveSpeed;
public float jumpSpeed = 8.0F;
public float duckSpeed = 8.0F;
private Vector3 moveDirection;
// public float gravity = 20.0F;
void Update()
{
moveDirection = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
if (Input.GetButton("Jump"))
{ moveDirection.y = jumpSpeed; }
if (Input.GetButton("Duck"))
{ moveDirection.y = duckSpeed; }
}
void FixedUpdate ()
{
GetComponent<Rigidbody>().MovePosition(GetComponent<Rigidbody>().position + transform.TransformDirection(moveDirection) * moveSpeed * Time.deltaTime);
}
}
i faund the rotesin js
#pragma strict
var x : float; var y : float; var z : float;
//public var turnSpeed : float = 50f;
//function OnTriggerStay (other : Collider) { if (other.attachedRigidbody ) other.transform.Rotate(Vector3(x, y, z),-turnSpeed * Time.deltaTime);}
function OnTriggerEnter (other : Collider) {
if (other.attachedRigidbody)
other.transform.Rotate(x, y, z);
//(Vector3(x, y, z)//, -turnSpeed * Time.deltaTime);
}
Your answer
Follow this Question
Related Questions
My Player rotates on the Z axis, but not the X axis. Why? 0 Answers
Camera not rotating alongside player character after new script. 0 Answers
How to organise game data for multiplayer with a player manager? 0 Answers
FPS camera jitters while moving and turning 0 Answers
Controller Rotation returns to Zero when there is no movement. 0 Answers