#Custom Animated Reticles

56 messages · Page 1 of 1 (latest)

pale ivy
#

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.

#

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

sharp hazel
pale ivy
#

I assume this has something to do with DPI and such

#

For reference, this is the tutorial I was using

sharp hazel
# pale ivy I can, but the problem is that I need to map the custom cursor to the user's mou...

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.

pale ivy
#

Ah

#

I'll look into that

pale ivy
#

if so, I have no clue how to make an animated bitmap

sharp hazel
# pale ivy wait, does the Godot function to change the mouse cursor, support bitmaps?

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

pale ivy
sharp hazel
# pale ivy 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.

pale ivy
#

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

sharp hazel
pale ivy
#

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

sharp hazel
#

Seems straight forward enough

pale ivy
#

yeah, but everything seems straightforward on paper

#

execution is where everything gets all fucky

pale ivy
sharp hazel
#

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

pale ivy
#

don't know what that means

sharp hazel
#

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

pale ivy
#

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

sharp hazel
#

Raycast?

pale ivy
#

Probably I'm not gonna lie

pale ivy
#

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