Hi,
I’m currently using this (slightly adapted) PlayerController script which I copied from here:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float movementSpeed = 9.0f;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
var z = Input.GetAxis("Vertical") * Time.deltaTime * movementSpeed;
transform.Rotate(0, x, 0);
transform.Translate(0, 0, z);
}
}
I’d like to make the movement speed when moving backward into say 70% of normal.
I tried using an if statement on z saying that if z<0, z=0.7*z, but that didn't seem to work since apparently z was a double which couldn't be turned into a float without a cast. I didn't want to cast since (according to MS) "Casting is required when information **might be lost** in the conversion, or when the conversion might not succeed for other reasons. "
Anyone know how to solve this?Thanks in advance!