My FPS-type game is allowing characters to walk through walls. I see that it’s because my code moves them with transform, rather than a character controller, so the collisions aren’t detected.
I’m trying to adjust the code to work with the information on this page (Unity - Scripting API: CharacterController.Move) , but i can’t seem to figure it out.
MY CURRENT CODE: (it moves less than .1 each directly / frame)
playerObject.transform.position.z += ((z2ios * 200 * distanceMultiplierRight) * Time.deltaTime);
playerObject.transform.position.x += ((x2ios * 200 * distanceMultiplierRight) * Time.deltaTime);
CODE I’M WORKING WITH BUT CAN’T FIGURE OUT:
var moveDirection = Vector3(((x2ios * 200 * distanceMultiplierRight) * Time.deltaTime), 0, ((z2ios * 200 * distanceMultiplierRight) * Time.deltaTime));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= 6.0;
var controller : CharacterController = GetComponent(CharacterController);
controller.Move(moveDirection * Time.deltaTime);
Anyone know where I’m going wrong?