Help me please! (767171)

Ok I have a question I would like make a Game but there is one thing. Its a Flight Simulator and I would like to make a adjustable Speed but I don’t everything about this. The Speed changes with the Mouse Well

Ps. Im German my Englisch isnt good. Sorry for that :wink:

You will need to add to your player controller method Update, and inside it add var speed += Input.mouseScrollDelta * scrollSensitivity; Then just set scrollSensitivity somewhere and use speed for your character.

3 Likes

Thank you so much I will try this in few seconds. Oh one thing Method Update? Did you mean “void Update”?

If you help me in my other Thread I love you link below #nohomo

https://discussions.unity.com/t/766896

Ok i have write my code and that shows like this please help me again <3

using UnityEngine;
using System.Collections;

public class Flight : MonoBehaviour {

    public float Speed = 90f;
    public float scrollSensitivity = 40f;

// Use this for initialization
void Start () {
   
}

// Update is called once per frame
void Update () {
    var Speed = Input.mouseScrollDelta * scrollSensitivity;
    Vector3 moveCamTo = transform.position - transform.forward * 10.0f + Vector3.up * 5.0f;
    Camera.main.transform.position = moveCamTo;
    Camera.main.transform.LookAt (transform.position);

    transform.position += transform.forward * Time.deltaTime * 90.0f;

    Speed -= transform.forward.y * Time.deltaTime * 2.0f;

    if(speed < 35.0f){
    speed = 35.0f;
}

transform.Rotate( Input.GetAxis("Vertical"), 0.0f, -Input.GetAxis("Horizontal") );

float terrainHeightWhereWeAre = Terrain.activeTerrain.SampleHeight( transform.position );

if (terrainHeightWhereWeAre > transform.position.y) {
    transform.position = new Vector3(transform.position.x,
                                    terrainHeightWhereWeAre,
                                    transform.position.z);
}
}
}