Solved - Pickup weapon with a keybind

There are no stupid questions, just stupid answers.
  • 1
  • 2
15 posts Page 1 of 2
SqHd
Posts: 55
Joined: Tue Apr 14, 2015 5:02 am
by SqHd » Sun Nov 22, 2015 8:33 pm
Is there an easy way to pick up a weapon or ammo with a keybind instead of on collision?
Currently, when walking over a weapon, it's added to inventory. Also, you can throw the weapon (alt + w) or ammo (alt + a).
Thanks!
Last edited by SqHd on Fri Mar 25, 2016 2:34 am, edited 1 time in total.
Nils
Posts: 213
Joined: Thu Feb 05, 2015 3:32 am
by Nils » Mon Nov 23, 2015 2:11 am
There's a script example in the "Torque 3D Game Development Cookbook" on page 154 -> Google books

The are also some resources about it on http://www.garagegames.com/community/resources, a bit old but should be working.
SqHd
Posts: 55
Joined: Tue Apr 14, 2015 5:02 am
by SqHd » Mon Nov 23, 2015 4:13 am
Thanks the Cookbook script worked great.
Now I just need to figure out how to apply it to weapons and mounting the image in the characters hands.
Dwarf King
Posts: 185
Joined: Thu Feb 05, 2015 7:20 pm
by Dwarf King » Mon Nov 23, 2015 3:03 pm
Thanks the Cookbook script worked great.
Now I just need to figure out how to apply it to weapons and mounting the image in the characters hands.

Code: Select all

%player.setInventory(RocketLauncher, 1); %player.setInventory(RocketLauncherAmmo, %player.maxInventory(RocketLauncherAmmo)); %player.mountImage(RocketLauncherImage, 0);
As a simple example :D
SqHd
Posts: 55
Joined: Tue Apr 14, 2015 5:02 am
by SqHd » Mon Nov 23, 2015 5:39 pm
Thanks. But I'm not sure where to put that code.
Should it be in the serverCmdPickupObject function somewhere?
(Trying to be able to pick up weapons with a keybind instead of collision)
Dwarf King
Posts: 185
Joined: Thu Feb 05, 2015 7:20 pm
by Dwarf King » Mon Nov 23, 2015 6:46 pm
Thanks. But I'm not sure where to put that code.
Should it be in the serverCmdPickupObject function somewhere?
(Trying to be able to pick up weapons with a keybind instead of collision)
It could be put almost anywhere. If you collided with the weapon you could throw the code in as a callback somehow or as a trigger or upon spawn. It all depends on your needs. The code example above is from an example where the code is executed during a spawn.

Se here:
http://www.garagegames.com/community/re ... view/21002

The scripting system is as such very flexible.

I guess you could make some serverCmdFunctionName in commands.cs and call it from the default.bind.cs file upon keystroke hit :D
SqHd
Posts: 55
Joined: Tue Apr 14, 2015 5:02 am
by SqHd » Tue Nov 24, 2015 3:44 am
I'll give it a shot. (Scripting newb here!)
Dwarf King
Posts: 185
Joined: Thu Feb 05, 2015 7:20 pm
by Dwarf King » Tue Nov 24, 2015 11:25 am
I'll give it a shot. (Scripting newb here!)
Steve Acaster made some real good tutorials:
http://www.garagegames.com/community/re ... D/101767/3

The simple fps tutorial takes you through all the basic step by step and in no time you get the hang of it :)
SqHd
Posts: 55
Joined: Tue Apr 14, 2015 5:02 am
by SqHd » Tue Nov 24, 2015 5:27 pm
Thanks for the link. It may be time to learn TorqueScript!
And I've heard of the great Steve Acaster... 8-)
LukasPJ
Site Admin
Posts: 444
Joined: Tue Feb 03, 2015 7:25 pm
 
by LukasPJ » Wed Nov 25, 2015 3:03 pm
If you are trying to learn TorqueScript, remember that we have a Wiki:
http://wiki.torque3d.org/wiki:_scripter-start
Lots of great stuff there :)
  • 1
  • 2
15 posts Page 1 of 2

Who is online

Users browsing this forum: No registered users and 6 guests