- Home /
Character Controller PC versus Mac Problem
I have a character controller on my player object. I have my own script that I use to move it. It is very simply. Here are the entries on the controller:
slope limit 45, step offset .1, skin width .1, min move 0, center 0,0,0, radius .5, height 1.3.
Here is the script I use to move it:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(CharacterController))]
public class MovementScript : MonoBehaviour
{
public bool Enabled { get; set; }
public float f_speed;
public float f_gravity;
private CharacterController controller;
private Vector3 moveDirection = Vector3.zero;
void Start ()
{
controller = GetComponent<CharacterController>();
Enabled = true;
}
void Update ()
{
if (Enabled)
{
if (controller.isGrounded)
{
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= f_speed;
}
moveDirection.y -= f_gravity;
controller.Move(moveDirection * Time.deltaTime);
}
}
}
When I build this on my Mac everything works perfect. If I build an output PC.exe file and run it on the PC then the player tries to go straight up in the air instead of any other direction.
On the Mac if I hit W the character goes forward, S he goes backward, A he slides to the left and D to the right. As I said, he works perfect.
If I build for PC and run it on a PC then he ALWAYS goes UP instead of the direction like on the Mac.
If I open Unity and open the project on the PC I get the same bad results running in the editor. I have added logging on the PC to see if the horizontal and vertical values are correct and they are.
I am running the same version of Unity on the Mac and PC.
What the heck is going on?
EDIT: I just uploaded a test project that demonstrates the problem: Test Project If you Play it on Mac it works fine. If you Play it on Windows it doesn't move as it should.
I also have built a web player version of it. If you go to this on a Mac it works fine. If you try it on Windows it doesn't work. I use Chrome on both. Here is the link: http://www.shatalmic.com/cctest
Shot in the dark. Does your PC have a game controller or other device that could be mapped to "Horizontal" or "Vertical?"
Thank you for the try, but no. It is like there is just some setting or bug that ignores the input vector and always makes the character go straight up.
Answer by Hotshot10101 · Jul 04, 2013 at 05:29 PM
I received a reply from Unity QA saying they were able to reproduce the issue and to watch for an update in the release notes of future updates to Unity. Guess I will have to wait and see.
Did you ever find a solution to this bug? I'm having a very similar problem. I even moved the whole project to my PC and the issue still occurs in the editor.
In Windows, my Character Controller only moves in -X/-Y/-Z. Sometimes moves +X/+Y like it is dragging through mud, and never moves +Z. It correctly moves in all directions on $$anonymous$$ac. Really puzzling.
Answer by jococo · Oct 06, 2016 at 06:54 AM
was this ever fixed or is there a work around? Using Unity 5.4.0.
Your answer
Follow this Question
Related Questions
iPhone development in Unity 3.0 using PC + MAC? 1 Answer
A node in a childnode? 1 Answer
PC and Mac builds FPS different? 2 Answers
Cannot find dll file in Unity folder (Mac) 1 Answer
Stop the dialogue box from appearing on PC/Mac builds 2 Answers