So this should we very simple. I am very new to Unity and I am trying to get my cube to move and also be able to change it scale when pressing my key P (Maybe also descale). (The movement is working).
Here is my script:
Code (CSharp):
- using UnityEngine;
- using System.Collections;
-
- public class CubeScript : MonoBehaviour {
-
- public float rotationSpeed;
- private Vector3 direction;
- // Use this for initialization
- void Start () {
-
- }
-
- // Update is called once per frame
- void Update () {
- float v = Input.GetAxis (“Vertical”);
- float h = Input.GetAxis (“Horizontal”);
-
- rotate ();
- }
- if (Input.GetKey (KeyCode.P)) {
- Bigger();
-
- movement (direction);
- }
-
- void rotate(){
- transform.Rotate (direction, rotationSpeed * Time.deltaTime);
-
- }
- void movement(Vector3 movementDirection){
- transform.position += movementDirection * Time.deltaTime;
- }
- void Bigger(){
- transform.localScale += new Vector3(0.5f,0,0);
- }
-
-
- }
-
I am also getting an error telling me “Keyword `void’ cannot be used in this context” and an Unexpected Symbol Error.
-Thanks!