Flashlight Viewmodel?

Grab your favourite IDE and tinker with the innards of game engines

Flashlight Viewmodel?

Postby Cpl Bradley on Wed Aug 17, 2011 2:33 am

How would I go about making it so that when you activate your flashlight it shows a viewmodel, and hides it when you turn the flashlight off? I've already animated and compiled the model, so its ready to go.
Cpl Bradley
Member
Member
 
Joined: Fri Jul 30, 2010 11:32 pm

Re: Flashlight Viewmodel?

Postby Cpl Bradley on Wed Aug 17, 2011 2:34 am

This is for the source engine if you can't tell.
Cpl Bradley
Member
Member
 
Joined: Fri Jul 30, 2010 11:32 pm

Re: Flashlight Viewmodel?

Postby Jangalomph on Thu Aug 18, 2011 2:50 am

I guess... just do some kind of unholster kind of thing as they do in the weapon code?
http://www.nomoreroominhell.com
I don’t know whether I was right or wrong, I guess I’ll never know… But I made it. And I guess I should be thankful for that. - Strelok
Has anyone really been far even as decided to use even go want to do look more like?
User avatar
Jangalomph
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Wed Jun 25, 2008 3:19 pm
Location: Sumter, SC

Re: Flashlight Viewmodel?

Postby pk_hunter on Thu Aug 18, 2011 3:41 am

Would this be wielded with a weapon or separately?
Image
User avatar
pk_hunter
Pheropod
Pheropod
 
Joined: Thu Oct 23, 2008 4:05 pm
Location: Glasgow, UK

Re: Flashlight Viewmodel?

Postby LordDz on Thu Aug 18, 2011 9:10 pm

Make a new weapon, copy and paste the flashlight code in it ? instead of having "F" button you use the fire button to activate it.
User avatar
LordDz
May Contain Skills
May Contain Skills
 
Joined: Mon Sep 01, 2008 12:28 pm
Location: Hammer Crash Logs

Re: Flashlight Viewmodel?

Postby Surfa on Fri Aug 19, 2011 1:12 pm

This is actually rather simple to do. You toggle the flash-light using the console command impulse 100 so if you a search for this in the code you should be able to find the section that toggles the flash-light when the button is pressed and then remove that and just place this code in the primary attack section of the weapon you make. Also to make it better and similar to how awesome it is in NMRiH create a bone at front of the model and attach the projected-texture for the flash-light to this in the code.
Surfa
May Contain Skills
May Contain Skills
 
Joined: Sun Dec 30, 2007 3:04 pm

Re: Flashlight Viewmodel?

Postby Cpl Bradley on Sun Aug 21, 2011 6:28 am

Alright what I was originally gonna do is make it be able to draw while holding another weapon, but now it will be a completely separate weapon. Thanks for the advice.
Cpl Bradley
Member
Member
 
Joined: Fri Jul 30, 2010 11:32 pm

Re: Flashlight Viewmodel?

Postby Cpl Bradley on Sun Aug 21, 2011 6:31 am

One more question, what would I use to make it run impulse 100 when the weapon draws?
Cpl Bradley
Member
Member
 
Joined: Fri Jul 30, 2010 11:32 pm

Re: Flashlight Viewmodel?

Postby dark0r on Sat Oct 29, 2011 11:31 am

Just do something like:
Code: Select all
void MyWeapon::Deploy()
{
    GetPlayerOwner()->FlashlightOn();
}


Code: Select all
void MyWeapon::Holster()
{
    GetPlayerOwner()->FlashlightOff();
}


Simple. Then remove the "impulse 100" code so the player can't toggle flashlight on/off.
dark0r
Been Here A While
Been Here A While
 
Joined: Sat Mar 25, 2006 10:16 am
Location: de_hell

Re: Flashlight Viewmodel?

Postby Jordash on Sat Oct 29, 2011 3:55 pm

This is a tutorial on the viewmodel attachment which surfa mentioned http://forums.steampowered.com/forums/s ... p?t=848105
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Return to Programming

Who is online

Users browsing this forum: No registered users