[intro]
Hello guys,
I guess you’ve read this hundreds of times, but …here i go as well:
I’m new here, been unemployed due to current situation so I want to learn Unity.
It’s just my second day here, and i need a little help as I’m stuck.
Problem:
I’m following a tutorial, got to the scripting bit, followed exactly (at least i think so), his script works, mine doesn’t.
I keep getting errors, such as:
***error CS0103: The name ‘thrust’ does not exist in the current context
***error CS1061: ‘Transform’ does not contain a definition for ‘EulerAngles’ and no accessible extension method ‘EulerAngles’ accepting a first argument of type ‘Transform’ could be found (are you missing a using directive or an assembly reference?)
***error CS1061: ‘Vector3’ does not contain a definition for ‘X’ and no accessible extension method ‘X’ accepting a first argument of type ‘Vector3’ could be found (are you missing a using directive or an assembly reference?)
It’s my mistake somewhere, i’m the idiot i guess, but i really want to learn unity and I guesswe all started somewhere…
Thank you for the help
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Move : MonoBehaviour
{
public float rotationSpeed = 5f;
public float thrustForce = 10f;
public Joystick joystick
float rotationX, rotationY;
Rigidbody2D RB;
// Start is called before the first frame update
void Start()
{
RB = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (joystick.Horizontal != 0f || joystick.Vertical != 0f) {
rotationX = joystick.Horizontal * rotationSpeed;
rotationY = joystick.Vertical * rotationSpeed;
}
if (Input.GetButtonDown("Jump")) {
Thrust();
}
}
private void FixedUpdate()
{
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, -(Mathf.Atan2(rotationX, rotationY) * Mathf.Rad2Deg));
}
public void Thrust()
{
Vector2 force = transform.up * thrustForce;
RB.AddForce(force);
}
}
(sorry, did not know about the code button :] )