I can't be the only one having this problem right. Essentially, in Gadot if you want to make a custom cursor there are only 2 ways from what I know. You make a sprite 2d texture that you can animated, or change via code, and you update it's position based off of the user's mouse movement. The problem with this is that it's not the most responsive as the custom cursor will often become sluggin, or inaccurate to where the user's mouse actually is. The 2nd way which is the more common one is that you code the custom cursor in, to physically replace the user's mouse so that it's responsive and perfectly alligns. The problem I'm having is that this method forfeits the animated aspect of the customer cursor, forcing you to use the static png as a replacement, unable to edit it via sprite animations or code.
#Custom Animated Reticles
56 messages · Page 1 of 1 (latest)
here's the code I have right now for the custom cursor replacement.
the game looks like this at the moment
the cursorSprite.rotation code doesn't actually work properly
There may be a more effective solution out there, I'd have to experiment but you could ether animate the cursor outside Godot, and call Input.SetCustomMouseCursor in _Process while cycling through the animated sprites. Or you could learn to animate the cursor inside Godot using Image and ImageTextures and use that while calling SetCustomMouseCursor in _Process.
I can, but the problem is that I need to map the custom cursor to the user's mouse movement, but as I've said it lags behind greatly for some reason
I assume this has something to do with DPI and such
For reference, this is the tutorial I was using
In this video we'll look at the right and wrong way to use a custom cursor in Godot, along with some additional functionality that the engine supports so that you can swap graphics on the fly or even use an entire suite of cursors for your project.
Source code and transcript: https://shaggydev.com/2021/09/28/custom-cursors/
Official document...
Sorry for the confusion, I'm not saying you should make a sprite and move that sprite every frame, I'm saying you should make a sprite and set it as the custom cursor every frame. You can't just rotate the sprite though, you have to change the bitmap itself if you want to animate it. You can do that easily outside Godot, or you can look up how to do it with Image and ImageTextures.
wait, does the Godot function to change the mouse cursor, support bitmaps?
if so, I have no clue how to make an animated bitmap
Sorry, a bitmap is any digital image produced by setting color values to pixels. I used it to express that however you decide to animate the image, you need to change the bitmap (the pixels) itself to reflect that animation. This is why it's easiest to do outside of Godot, but more flexible if you use Image/ImageTexture to modify the pixels using code
I would use image texture animations but unfortunately...
Imagine you have the image you want to animate. You go into photoshop, rotate it by 22.5 degrees, and save it as a new image. You do this until you have one full rotation.
You now have 15 images reflecting your desired animation.
You use set_custom_mouse_cursor with the first image.
A few _process frames later, you set_custom_mouse_cursor to the second image.
Then the third, forth, etc.
You now have an animated cursor.
With that done, if you decide it's worth the effort, you do the whole thing again, but instead of using photoshop, you use Image/ImageTextures inside Godot to create the bitmaps you require.
I think I might just ultimately change the way I'm trying to do this
essentially, I'm trying to make a 2d reticle that stays close to the character, that allows them to aim
let me draw it out rq
they tilt the R stick to aim in any direction
That works too 👍
when they press the shoot button, it shoots a grappling hook
and it hooks them onto the nearest surface
that's the gyst of this mechanic I'm trying to make
Seems straight forward enough
yeah, but everything seems straightforward on paper
execution is where everything gets all fucky
Here's a perfect example of what I'm trying to do from a game called Webbed
Hmmmm, I think you could get most of the way there using a seek steering behavior. So you wouldn't have to resort to RigidBodies
don't know what that means
It's a way of moving a character in relation to a target. Seek is simple enough that it often produces undesired movement paths, but may be exactly what you want for a grapple/swing system. I'll let you google it for details
ok, so miraculously I got it working
here's the code I did
now all I need to do is make sure that the reticle collides with the physical objects in the scene
Raycast?
Probably I'm not gonna lie
Quick Ask
Did they change the cast_to parameter for RayCast2D to the target_postion parameter
if so, what the hell does cast_direction even do now, since it still allows it as an option, yet there's nothing in the Godot Documents that even mentions it
this is what it looks like so far
the reticle is supposed to stop when colliding with the physical terrain, but it's not
and for some reason the dotted line indicator gets all buggy when I point downwards
important to note that I have it print a message to console whenever the raycast is detected colliding with something