Pages: 1
Topic closed
Hi,
I want to basically make something so when you hold a key down then release it, upon release it sends an action. More specifically.. to "shoot" an object across the room... If you ever played Half Life 2, I'm trying to recreate the gravity gun. I have the script already to pick things up, however, I also need to figure out how to have it only pick 1 item up at a time. But essencially I want to hold space down to hold the item with the gun, then when you release space it shoots the object in the direction the player is facing.
Any ideas? I've tried a bunch of things but nothing seems to be working. I want to stick to 1 key for hold and release... i've had it working with 2 keys but I like just 1. Thanks!
Offline
Would something like this work?
[when green flag clicked)
[forever]
[][wait until <key [space] pressed?>]
[][action for picking up the item goes here]
[][wait until <not <key [space] pressed?>>]
[][action for releasing the item goes here]
[end forever]
Last edited by Jonathanpb (2010-09-24 00:49:06)
Offline
the wait until's cause the object to not move for some reason.. leme put what i have
http://i46.photobucket.com/albums/f101/msobyak1/scripts.jpg
the script on the left is my attempt at 1 key function. the script on the right is 2 keys. The Wait Until makes the object the gun is picking up not move at all no matter where I put it. I tried an <If not key pressed > with in the <if key pressed> but it doesn't recognise the statement.
Offline
ok i think i have it working, could use velocity to make it more smooth like I had it in the other version. But here is what I have now:
http://i46.photobucket.com/albums/f101/msobyak1/scripts2.jpg
Now the question is: How do I get to only effect 1 object up at a time? Meaning not only do i not want it to pick 2 objects up, but I dont even want it to pull 2 objects at the same time.
Offline
yeah i was thinking that, just wonder what would happen if 2 objects were the same distance if it would get confussed. Is there a way to put colission on the objects as well? so they cant share the same exact x/y posission? this is a prototype for taking it into a 3d program so I'm tryin to think ahead as well. If there are 100 items you can pick up, would get pretty taxing to do distances between every object.
Offline
Oh, there's a lot of objects? That could make it difficult. I suppose you could have the items store their positions in lists, and somehow order them (maybe my x position) to make it easier to manage all the data.
Offline
Topic closed
Pages: 1