i am trying to use istouching to wait until an ent is being touched by the player can someone say me a better way of doing this as my while and for loops keep acting as if the player would be touching the ent while it's not D:
i am trying to use istouching to wait until an ent is being touched by the player can someone say me a better way of doing this as my while and for loops keep acting as if the player would be touching the ent while it's not D:
I use something like this:
Code Snippet
Plaintext
ent = getent("name","targetname"); ent thread touchme(); touchme(){ while(1){ players = get_players(); for(i=0;i<players.size;i++) { if(players[i] istouching(self)){ //do something if player is touching ent }
} wait(.5); } }
Last Edit: April 18, 2014, 05:56:24 am by MakeCents
Place a trigger_multiple around the entity and waittill("trigger")... Done.
- Phil.
Side note, kind of.... I am assuming he wants this for the car ride script, where the vehicle is moving. I have a moving thing in my map as well. I have been working through things I didn't like about it, just before this post. I attempted linking the trigger or moving the trigger, but failed. I just figured you were not able to and I addressed it other ways and finally settled with a script similar to the previous one I mentioned. I would prefer to link the trigger to it. Do you know if trigger move or trigger linkto is possible?
no i dont want it for the car ride and i cant use a trigger cause the thing that player is supposed to touch spawns when a zombie dies. so i cant spawn a trigger or put one in the specific place where it died Post Merge: April 18, 2014, 04:01:47 pmand makecents, i dont think that trigger link to is posible cause yesterday i tried to use movez with a trigger and everything moved fine except for the trigger
Last Edit: April 18, 2014, 04:01:47 pm by jjbradman
It is possbile, you have to EnableLinkTo(). Also, you can spawn a trigger_radius via script. But if it is something powerup-like (where there might be more), it would indeed be better to use IsTouching() or even just a proximity check (DistanceSquared()) like the powerups do.
It is possbile, you have to EnableLinkTo(). Also, you can spawn a trigger_radius via script. But if it is something powerup-like (where there might be more), it would indeed be better to use IsTouching() or even just a proximity check (DistanceSquared()) like the powerups do.
- Phil.
Wow, you're AWESOME. Can't believe that was the answer. Thanks so much. Now I can get rid of those nested loops and just thread a loop once.
It is possbile, you have to EnableLinkTo(). Also, you can spawn a trigger_radius via script. But if it is something powerup-like (where there might be more), it would indeed be better to use IsTouching() or even just a proximity check (DistanceSquared()) like the powerups do.
- Phil.
actually the trigger radious idea i think is better o.O that way the script could wait till the trigger has been touched? o.O
but the trigger radious would be deleted within 15 seconds of being spawned anywas and only 1 zombie in every 10 zombies would need the radious to be spawned