2D/3D Moving the Player down the Z Axis and X Axis
Hey I have a problem concerning the movement Im really new to that but sadly even such a basic thing stops me from continuing. void FixedUpdate() {
//grounded
grounded = collided = Physics.CheckSphere(groundCheck.position,groundCheckRadius,groundLayer);
myANim.SetBool("isGrounded", grounded);
myANim.SetFloat("verticalSpeed", myRb.velocity.y);
// Z Axis
//horizontal
float move2 = Input.GetAxis("Horizontal");
myANim.SetFloat("speed", Mathf.Abs(2));
myRb.velocity = new Vector3(move2 * maxSpeed, myRb.velocity.y, 0);
This is the Code I use to walk LEFT and RIGHT. It works quite good but I want to build it out abit Cause I want the Player to move little bit on the Z Axis as a "Pseudo Y Axis" cause I do a 2D Game with 3D Mechanics.
I tried it with
if (Input.GetKey(KeyCode.S))
{
transform.position -= new Vector3(0.0f, 0.0f, speed * Time.deltaTime);
transform.localScale += new Vector3(0.001f * speed, 0.001f * speed, 0.001f * speed);
To make the Player go towards the camera but
Even though:
the player has 2 colliders , a Rigidbody, colliders around the "Map"
he falls down the Z Axis. I put on all sides Invisible colliders. When he walks to the left or right he stops infront of the colliders but when I use W or S he falls down..almost like he ignores the colliders. The Playerobject has 3D Physics a Rigidbody and cube and spehere colliders
What can I do?