Home > other >  Unity3d small white help, code don't know where is wrong
Unity3d small white help, code don't know where is wrong

Time:09-19

Using System. The Collections;
using System.Collections.Generic;
Using UnityEngine;

Public class Shooter: MonoBehaviour {

Public Rigidbody bullet;
Public float power=1500 f;
Public float moveSpeed=2 f;

Void the Update () {
Float h=Input. GetAxis (" Horizontal ") * Time. MoveSpeed deltaTime *;
Float v=Input. GetAxis (" Vertical ") * Time. MoveSpeed deltaTime *;
The transform. Translate (h, v, 0);
If (Input. GetButtonUp (" Firel ")) {
Rigidbody instance=Instantiate (bullet, the transform. The position, the transform, rotation) as Rigidbody;
Rigidbody. AddForce;
Vector3 FWD=transform. TransformDirection (Vector3. Forward);
The instance. AddForce (FWD * power);
}
}
}

CodePudding user response:

Water watershui

CodePudding user response:

Which is the key "Firel"?
Do you want to write "Fire1"? You are to invoke the keys?
The scarlet letter is what the devil, AddForce not static method, must have a Rigidbody objects can call ah,
Is a compiler error, or run went wrong?

CodePudding user response:

Currently visible problem 1: no assignment Firel buttons, need to first make a public KeyKode Firel; And then specify the button
2: Rigidbody. AddForce; This function is need parameters,
  • Related