Experiencepoints

  • Feb 25, 2022
  • Joined Dec 13, 2021
  • 0 best answers
  • @DaveTheCoder said: Here's some code I'm using for a RigidBody2D.

    speed and dir are floats. dir is the direction in radians, in the range -PI to PI, measured clockwise from the positive X-axis. linear_velocity is a Vector2 property of a RigidBody2D.

    	# Set velocity (speed and direction).
    	# First set the velocity vector along the positive X-axis, using the specified speed.
    	# Then rotate the velocity vector to the specified direction.
    	linear_velocity = Vector2(speed, 0.0).rotated(dir)

    I am trying to use the rotated() function in 3D, and it says to put an axis for argument 1, how would I signify I want to use the Y axis? The documentation doesn't really say.

  • Thanks! I just realized the layer min and max for the light I am using for masking were both set to 0, so I set them both to 2 and set the CanvasLayer's layer to 2, and it works!

  • I am using masking in my UI, and for some reason it stops working when I put it in a CanvasLayer. Is there a way to fix it?

  • I want an object to move in the direction it's facing, but I'm not sure how to do that. I used some code with sin() and cos() that worked before in a different engine, but it doesn't seem to be working here. How do you make something move in the direction it's pointing in Godot? (2D)

  • Ok thanks! I have no idea why I didn't think of using atan2, I used to use it all the time when I made games with processing.js.

  • Yeah, I saw that, but I am not sure how to set a sprite's direction to the Vector2. I tried assigning the Vector2 to a Sprite.direction and it didn't work.

  • It was helpful for one of the things, but I found nothing about how to see what direction you're pointing the joystick in.

  • I am making a game that is primarily going to be played with a controller, and I've ran into a few things I haven't been able to figure out on my own or in the documentation. First, is there a way to detect how far you are pushing the joystick? And if so, how do you use it? And second, how do you detect the direction it is being pushed in?