So I have this code used for my character to move left and right and also jump. I also made it so that when I moves left, the sprite flips to face the left direction. One big issue though is that when I make the camera the player’s child to make it follow the player, the camera flips completely to the other side when turning left instead of staying on one side. And when doing lighting effect, the light only effects the player when moving right, but not when moving left. Is there a way I can make the light impact the player while facing both left and right, while also having the camera not constantly flip sides when turning when it’s the player’s child object?
Thank you
My code is here:
using UnityEngine;
using System.Collections;
public class smallbot_movement : MonoBehaviour {
public float moveSpeed;
public float jumpHeight;
void Update(){
Movement ();
}
void Movement()
{
if(Input.GetKey (KeyCode.D))
{
transform.Translate(Vector2.right * moveSpeed * Time.deltaTime);
transform.eulerAngles = new Vector2(moveSpeed, 0);
}
if(Input.GetKey (KeyCode.A))
{
transform.Translate(Vector2.right * moveSpeed * Time.deltaTime);
transform.eulerAngles = new Vector2(moveSpeed, 180);
}
if(Input.GetKeyDown (KeyCode.Space))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(0, jumpHeight);
}
}
}