generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do I make an FPS Arrow?

Previous Thread :: Next Thread 
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 03:59 PM
I am trying to make one of those arrows that are common in FPSs that point to an enemy when they shoot you. I really have no idea how to do this. Anyone know how?

--Last time I asked for help with this, I just wound up in an argument with a bunch of trolls, and I really don't want any trouble, so please no unnecessary comments.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:02 PM
Would this be 3D or 2D? Never seen one of these honestly. Ill try to understand.
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:04 PM
There's one in pretty much every popular FPS; Arsenal, Phantom Forces. It is a 2D ScreenGui, by the way.
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:09 PM
Bump.
Report Abuse
BaconOfDeath is not online. BaconOfDeath
Joined: 15 Jan 2013
Total Posts: 134
28 Jun 2016 04:11 PM
do you mean a crosshair?
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:13 PM
No. When an enemy shoots you, a 2D arrow Gui (which I already have) appears on your screen and points in the direction of the enemy.
Report Abuse
BaconOfDeath is not online. BaconOfDeath
Joined: 15 Jan 2013
Total Posts: 134
28 Jun 2016 04:15 PM
i would do something with billboardGuis for that
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:16 PM
So... When the enemy gets hit, grab the current positions of the player's torsos.

Let's pretend Player1 shoots Player2 and this is where the torsos are:

Player1 : {1, 4, 2}
Player2 : {4, 12, 7}

Ignore the Y value because it's not really needed if this is 2D. Now imagine this on a coordinate plane (you know, the kind you used in Algebra 1).

(1, 2) and (4, 7)

We can make a triangle out of that.

CORNER A: (1, 2)
CORNER B: (4, 7)
CORNER C: (4, 2)

You need the angle of the corner A, right? Some good ol' trigonometry should help here, as well as the distance formula.

I'd use the tangent stuff here so that you don't have to use ol' Pythagorean.

Alternatively, you could set the Y's of the Vector3's to 0 so you can use magnitude.

Either way, you can get the angle with trigonometry. And that will be the rotation of the arrow gui.


There may be some flaws in this, it's off the top of my head. Like, the very top of my head.

Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:17 PM
I would, except what if your not facing the enemy who shot you? You wouldn't see the Gui and wouldn't know which direction enemy fire was coming from!
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:17 PM
*Player2 shoots Player1, im sorry.
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:18 PM
Thank you for your help, Diamond, it's very thoughtful of you, but that method doesn't take into account the Frame of the player's camera.
Report Abuse
BaconOfDeath is not online. BaconOfDeath
Joined: 15 Jan 2013
Total Posts: 134
28 Jun 2016 04:19 PM
good point. i would use diamond's method, he/she seems a lot smarter than me
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:21 PM
@Axon Oh, so it doesnt show EVERY TIME you get shot? Explain. Does the player have to be able to see who shot them? Or does it show when they cant see who shot them?
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:22 PM
Yah, he really seems to know what he's doing.
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:24 PM
It goes like this: an enemy shoots you. The 2D arrow GUI appears on your screen. It is rotated to point to the player who shot you. Yes, it always appears, except when the shot is fatal and you die. If you want to see it in action play Arsenal. It has a pretty good one.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:27 PM
But what did you mean by "doesn't take into account the Frame of the player's camera"?

We could use an if statement here to see if a player is visible or not, if thats what you mean.
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:28 PM
You know, the CFrame of the player's camera. Its position and rotation in one ridiculously long 12 digit value. The CFrame will definitely be a determining factor in the rotation of the arrow.
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:29 PM
Did it type Frame by accident? Stupid spell checker.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:32 PM
Ah, true. Again, off the top of my head.

If this is a game locked in first person, you can do the same thing with the character's torso and an imaginary point in front of it. You can make this point with.... I believe it was Cframe.lookVector. Then you can Subtract the first angle we calculated from where the character is facing on a 2D plane as well.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:33 PM
Its okay! Though if you wanted something to happen only if a player could see the other, WorldToScreenPoint would have helped there :)
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:35 PM
That's the thing, it's not locked in first person. The game I'm making is going to be focused on battling with starfighters, not just FPSing. I'm not even sure if the arrow is that necessary.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:36 PM
You might be able to simply do the same thing with the camera. To get the imaginary point, possibly ScreenPointToRay.
Report Abuse
AxonMega is not online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
28 Jun 2016 04:53 PM
I think I have an idea, gonna try the WorldToScreenPoint function.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 04:54 PM
Let me know if you have any more issues. If not, give me a conformation that it worked :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image