Answer the question
In order to leave comments, you need to log in
How to set the directional movement of the character along the arrow?
I want to create a game like Hyper Dash! (here is the game itself ). But I can't set up the controls so that the character jumps in the direction of the arrow to opposite platforms (the number of platforms on the top is 6, on the bottom is 6). Help me please! I am new to programming.
At the moment I have this code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
private Rigidbody2D rb;
private bool top;
public float speed = 4f;
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rb.gravityScale *= -1;
Rotation();
}
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
void Rotation()
{
if (top == false)
{
transform.eulerAngles = new Vector3(0, 0, 180f);
}
else
{
transform.eulerAngles = Vector3.zero;
}
top = !top;
}
}
Answer the question
In order to leave comments, you need to log in
I can't watch the video. Judging by your description, you need to move towards the cursor. I made the cursor a separate object that moved the mouse, getting its coordinates is not a problem.
You need to get the direction vector from the player to the cursor, for this you need to subtract the player's coordinates from the cursor coordinates. ( https://docs.unity3d.com/en/530/Manual/DirectionDi... )
It is also worth studying: https://docs.unity3d.com/en/530/Manual/Understandi...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question