Problem with movement while rotating the character
Hello guys,I have a problem while im trying to rotate my character with MouseOrbit.I turn the screen 180o but my character is walking backwards,kinda like moonwalking,the same applies with right and left movement. Here is my script:
using UnityEngine;
using System.Collections;
public class player : MonoBehaviour {
public Animator anim;
private float inputH;
private float inputV;
public Rigidbody rbody;
float speed = 5f;
public Transform target;
// Use this for initialization
void Start ()
{
anim.GetComponent<Animator>();
rbody = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update() {
inputH = Input.GetAxis("Horizontal");
inputV = Input.GetAxis("Vertical");
anim.SetFloat("inputH", inputH);
anim.SetFloat("inputV", inputV);
float moveX = inputH * 50f * Time.deltaTime;
float moveZ = inputV * 50f * Time.deltaTime;
rbody.velocity = new Vector3(moveX, 0f, moveZ);
if (Input.GetMouseButton(0))
{
transform.LookAt(target);
transform.RotateAround(target.position, Vector3.up, Input.GetAxis("Mouse X") * speed);
}
}
}
This is a video to see what actual happening because my english syntrax sucks http://tinypic.com/player.php?v=70xqw3&s=9#.V53vRNKLQ6R
Also i will attach some images from the project
PS1 : I am new to unity, and i proably have made some mistakes,so be patient
PS2: Ignore the moving animation thats loops even is the character is still
Thanks in advance! :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612085909im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem with mouseorbit android 0 Answers
MouseOrbitImproved slanted orbit 0 Answers
Object rotation problem 1 Answer
Broken rotation (c#) 0 Answers
i'm using a code to make my cube walk with character controller but when i play the cube spins. 0 Answers