I have been trying to add slopes for my game when I noticed that my player sides down, I tried different ways of preventing this (too many to list) and nothing seems to be working.
Here’s my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class fpsmover : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
obj = GameObject.Find("camdirect");
speedbost = GameObject.Find("SpeedBost");
damagebost = GameObject.Find("DamageBost");
rb = GetComponent<Rigidbody>();
}
GameObject obj;
public GunShot script;
GameObject speedbost;
GameObject damagebost;
Rigidbody rb;
public float Speed = 10f;
public float Health = 100f;
public float SpeedBost = 2f;
public float DamageBost = 2f;
public float sensativity = 10.0f; //the speed we rotate to look at diffrent stuff
// Update is called once per frame
void Update()
{
Vector3 objPosition = new Vector3(obj.transform.position.x, transform.position.y, obj.transform.position.z);
transform.LookAt(objPosition);
float horz = Input.GetAxis("Horizontal");
float vert = Input.GetAxis("Vertical");
Debug.Log(horz);
float x = horz * Speed * Time.deltaTime;
float z = vert * Speed * Time.deltaTime;
this.transform.Translate(x, 0.0f, z);