- Home /
Question by
TanerPinarbasiDev · Mar 05 at 09:09 PM ·
physicsrigidbodyanimatorgravity
When I add to Rigidbody and Use Gravity, my character is start flying.
@TanerPinarbasiDev I am trying to create a cat controller. However when I add rigidbody and use gravity to my character. My character start flying. My code is below. How can I fix this situation.
Version: 2020.1.0f1
Video: https://youtu.be/S6gueRjHlmI
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuadroPedalController : MonoBehaviour
{
[SerializeField] float speed = 10.0f;
[SerializeField] float speedboost = 1.0f;
[SerializeField] float lerpSpeed = 5.0f;
public Rigidbody rigidbody;
Animator anim;
void Start()
{
anim = GetComponent<Animator>();
}
void Update()
{
movement();
UpdateCharacterBones();
}
void movement()
{
float translationX = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
float translationZ = Input.GetAxis("Vertical") * speed * Time.deltaTime;
var running = Input.GetKey(KeyCode.LeftShift);
var moveInput = Mathf.Abs(translationX) > 0.01f || Mathf.Abs(translationZ) > 0.01f;
anim.SetBool("isWalking", moveInput && !running);
anim.SetBool("isRunning", moveInput && running);
anim.SetFloat("VelocityX", translationX);
anim.SetFloat("VelocityZ", translationZ);
}
void UpdateCharacterBones()
{
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613053832im_/https://answers.unity.com/themes/thub/images/avi.jpg)