I have problem with vectors

I have this plane on my videogame. I`m trying to move the red to reach the green point, the red point has to move allways on the plane.
My issue is that the point is not moving on right direction. I think that is problem with vectors , but i don’t know how to define them for right moving.

Vector3 InputMovimiento; // Los vectores en los que nos vamos a mover con la pelota
Rigidbody rb; // Nos vamos a mover por fisicas
public float velocidad;// La velocidad de la pelota
public Transform punto_mover; // Para definir el punto que vamos a mover
public Transform puzzle; // Definimos el puzzle darle un raycast y que detecte el personaje
public float radio_puzzle; // El radio con el que el personaje detecte los puzzles
public LayerMask Personaje_LayerMask; // El layermask con el que el personaje detectara el puzzle
public bool puzzle_enable; //Bool para decirle cuando el puzzle puede mover el punto
public static Punto inst; // Para que el script sea comunicado con otros scripts
public Transform punto_final; // Para definir el punto final del puzzle
public Transform Celda; // Para definir la celda que vamos a mover con el puzzle
public bool cam_centrada;// Para bloquear el movimiento del personaje una vez este cerca del puzzle
public Transform Camara; // Para definir la camara con la que vamos a centrar la camara en el puzzle
public Transform Pos_Camera; // Posicion de la camara para ver el puzzle
public int tiempo_camara;// Velocidad a la que se desplaza la camara desde nuestro lado hasta el punto del puzzle

// Start is called before the first frame update
void Start()
{
rb = GetComponent();
cam_centrada = false; // Para que al empezar la camara centrada sea falsa . ya que no hay puzzles cerca

}

private void Awake()
{
inst = this;
}

// Update is called once per frame
public void Update()
{
puzzle_enable = Physics.CheckSphere(puzzle.transform.position, radio_puzzle, Personaje_LayerMask); // Creamos el raycast para saber si el personaje esta cerca del puzzle
InputMovimiento.y = Input.GetAxis(“Horizontal”);
InputMovimiento.y = Input.GetAxis(“Vertical”);

if (puzzle_enable == true && Input.GetKeyDown(KeyCode.E)) // Si estas cerca del puzzle y pulsas la e que el personaje deje de moverse y el personaje se centre en el puzzle
{
cam_centrada = true;

}

}

public void FixedUpdate()
{

if(cam_centrada == true)
{

rb.velocity =
punto_mover.transform.up * velocidad * InputMovimiento.y // Para que el monigote se mueva hacia delante

  • punto_mover.transform.right * velocidad * InputMovimiento.y// Para que el monigote se mueva de hacia los lados
    ;

}
}

8480399--1127441--Captura de pantalla 2022-09-30 195920.png

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

What is often happening in these cases is one of the following:

  • the code you think is executing is not actually executing at all
  • the code is executing far EARLIER or LATER than you think
  • the code is executing far LESS OFTEN than you think
  • the code is executing far MORE OFTEN than you think
  • the code is executing on another GameObject than you think it is
  • you’re getting an error or warning and you haven’t noticed it in the console window

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run? what order does it run in?
  • what are the values of the variables involved? Are they initialized? Are the values reasonable?
  • are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

Knowing this information will help you reason about the behavior you are seeing.

You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as Debug.Log("Problem!",this);

If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

You could also just display various important quantities in UI Text elements to watch them change as you play the game.

If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer or iOS: How To - Capturing Device Logs on iOS or this answer for Android: How To - Capturing Device Logs on Android

Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

When in doubt, print it out!™

Note: the print() function is an alias for Debug.Log() provided by the MonoBehaviour class.

You must find a way to get the information you need in order to reason about what the problem is.

Your scripts are only using the Y axis.