Jump to content

More realistic flashlight.


lxFirebal69xl
 Share

Recommended Posts

I was looking into improving the already implemented flashlight, but unfortunately my limited coding knowledge made me stuck pretty quickly, so here was my idea.

 

post-13811-0-64812700-1457902223.png

 

Have a flashlight model be a child of the fpsplayer (so it follows the mouses movement), line it up so it looks good, make a spotlight coming out of it, and then implement Hankinator's battery script to work with the new spotlight.

 

Battery script:

http://www.leadwerks.com/werkspace/topic/12783-flashlight-battery-tutorial/page__hl__flashlight

 

 

Problem is, I can't really figure out how to make it so that when the player presses F, the new spotlight appears and not the current one, and also how to implement the battery part of the code to work with it. (Since the battery script interacts with the player and not a child of the player)

 

Any guidance would be extremely helpful! Thanks!

Link to comment
Share on other sites

  • 3 weeks later...

Could you post some of your code?

 

Assuming you have an instance of a SpotLight you can hide and show it with the Hide(), Show() functions.

 

Psudocode:

function PlayerUpdate()
{
if window->KeyHit(Key::F)
{
   if splotLight->Hidden()
   {
    splotLight->Show()
   }
   else
   {
    splotLight->Hide();
   }
}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...