Jump to content

Targeting Reticule


Recommended Posts

How would I go about adding a targeting reticule that follows my mouse to a prefab? I'm adding a hat that allows throwing of explosives and I want the player to be able to see the range of the explosive if they were to throw it where they're currently mousing over.

Link to comment
Share on other sites

13 minutes ago, thomas4846 said:

Oof uhh have you already made a start onn it? or just asking how.

The rest of the Hat is in a slightly working order, but the targeting part isn't. I just don't know how to have something like that follow the mouse, specifically on the client side.

Link to comment
Share on other sites

19 hours ago, thomas4846 said:

Okay yeah sorry, so can you explain how the code works?

Because you may need to use a component or make your own from the forge weapons

Well, I don't have any code written yet for the reticule, that's why I'm asking for help. I looked into the forge weapons, but the code is almost unreadable even after some manually line making, the variables are all one letter and nothing is named.

Link to comment
Share on other sites

On 12/13/2020 at 4:13 AM, TheSkylarr said:

Well, I don't have any code written yet for the reticule, that's why I'm asking for help. I looked into the forge weapons, but the code is almost unreadable even after some manually line making, the variables are all one letter and nothing is named.

I feel really dumb for this comment I made, yes it was unreadable, but the code for all these items is still in the actual game code, no need for me to look at the mod.

After looking into it, although I successfully did everything required to add a targetting reticule to my item, it doesn't work due to a limitation of playercontroller.lua.

It seems that targetting reticules are implemented expecting only Hand slot items to have them, but in this case I want a hat to have one. I guess the only way to do this is gonna be in one of these ways, at least that I can think of.
 

  1. Make my own component based on Targetting Reticule that bypasses playercontroller somehow.
  2. Have my hat give the character a hand slot item for targetting, by temporarily storing  whatever item is in their hand slot in some invisible slot, and replacing it with the targetting one during the targetting. This may also simplify the process of throwing my item, as I can reuse the TOSS action from the game instead of making my own action.

Which one would be the best option here? I'm thinking option 2 myself, as it would make other parts of my code easier as well, but it seems a bit janky.

Edited by TheSkylarr
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...