- Quick Links - |
Visitor No.72282 |
- Random Picture - | ||||||
|
Attaching Things On Player
Let's attach things on player. I know you think I might be dumb because there is the certain verb called "AttachThingToThing(Ex)", but let's face it, you use that and for example you attach a saber handle on your chest, it goes nuts. It just attaches the position from the player, but not the pitch yaw roll stuff. So you turn around, face up etc, the saber handle will just funnily move around your chest, which isn't what I want. So, I just thought of a new way.
This works by firing the saber handle(take this as an example in this tutorial) all the time using FireProjectile, because it knows the PYR of the player, position of the player. (There should be a way to set the position, pyr of the saber handle manually with some "me-don't-know" vector calculation, but ask that to your professor or someone because I don't know. It should be less cpu usage, using SetThingPos, and SetThingLook)
Let's make this so that once you put your saber away, it will get the handle on your chest. The cog can just be created within "weap_saber.cog". First add pulse message for rapid creation of the saber handle. Add FireProjectile line with following parameters. Position_Vec = VectorSet(0.02, -0.01, -0.02); PYR_Vec = VectorSet(0, 0, 0); SaberOnChest = FireProjectile(player, handle_tpl, -1, -1, Position_Vec, PYR_Vec, 0, 0, 0, 0); We'll use the saber pickup as the base template, but since the 3do is way too big, I'll just resize it, and set the model through SetThingModel, so I don't need to go through all the static.jkl stuff as well. Add this line just below the above. SetThingModel(SaberOnChest, saberSmall); These are the reference to put for the saber. template handle_tpl=lightsaber local
Now that will shoot out the saber handle on your chest. If your 3do doesn't show up properly, change the value of the "Position_Vec" so it shows in the right position or/and change the value of the "PYR_Vec" so it's facing the right direction. You also have to destroy the saber handle, so it won't just stay there in the level forever. Add this following line on top of the codes shown above. if(SaberOnChest != -1) DestroyThing(SaberOnChest); Make sure you declare "SaberOnChest" in the symbols section as "-1" in the first place.
Now it shows the saber on your chest, let's tweak a few more in the cog so it shows up when you deselect saber, but take it off, when you select the saber again. In the newplayer and startup message, just add "SetPulse(0.01);" and in the selected message add "SetPulse(0);". So you have it on your chest when you respawn, or at the start of the level as well. Also in the startup add "SetInv(player, 10, 1);", so you have it in the first place. In the selected add this line after "SetPulse(0);", so the last handle won't stay there. if(SaberOnChest != -1) DestroyThing(SaberOnChest); In the deselected add "SetTimerEx(0.3, 3, 0, 0);" because there is a little delay the player will place the handle back on his chest. In the timer message add this after the other timer IDs. else if (id == 3) { SetPulse(0.01); }
Let's see how this thing can work!
|
This site is developed using PHP under Apache server Certain parts of this site require Cookie support. This site is best viewed with
Internet Explorer 5.5, Netscape 6.0, Opera 6.0 or Mozilla 1.0 and above |