Author Topic: Triggering Scripts When Player Hits Activate  (Read 7317 times)

Amran

  • Posts: 20
  • Maggot Crusher.
    • View Profile
Triggering Scripts When Player Hits Activate
« on: January 31, 2014, 05:21:40 PM »
Currently working on a custom level, and was wondering if there is a method or trick to creating a shape area which triggers a script when a player uses their attack/activate key within it.

If there's nothing built in that does this, maybe something similar can be accomplished using a collision polygon? Can these be made to detect hits, while not impeding player and projectile collision?

Enjay

  • Posts: 47
  • Maggot Crusher.
    • View Profile
Re: Triggering Scripts When Player Hits Activate
« Reply #1 on: January 31, 2014, 05:57:07 PM »
You can have a doodad being hit trigger scripts. This should be enough to get anything you need done, unless you're trying to have something activate-able in the figurative middle of nowhere, since most things you would want to activate are doodads. Alternatively, I see no reason why you couldnt make a square doodad that is completely transparent, able to be walked through, and has no shadow that would then trigger on being hit.
*Caveat: I do not know if objects that can be walked through can register hits, but I assume they can*
Every time I post I get nervous because I feel like the devs are judging me.

Myran

  • Developer
  • Posts: 183
    • View Profile
Re: Triggering Scripts When Player Hits Activate
« Reply #2 on: January 31, 2014, 06:00:14 PM »
Hm, you can try making a doodad with a physics shape that the player can walk through and set a ObjectEventTrigger to Hit, and see if it works. I'm not sure if it will work, but it might.


Set collision-response to false for a collision shape, like this:
Code: [Select]
<collision collision-response="false">
<circle offset="0 -2" radius="10" />
</collision>

Amran

  • Posts: 20
  • Maggot Crusher.
    • View Profile
Re: Triggering Scripts When Player Hits Activate
« Reply #3 on: February 01, 2014, 01:31:14 AM »
Hm, you can try making a doodad with a physics shape that the player can walk through and set a ObjectEventTrigger to Hit, and see if it works. I'm not sure if it will work, but it might.


Set collision-response to false for a collision shape, like this:
Code: [Select]
<collision collision-response="false">
<circle offset="0 -2" radius="10" />
</collision>

Ah, thanks! Using this, the ObjectEventTrigger does still register the hit, while players are able to walk through it. (Although it does stop projectiles in order to register the hit, and also can't be triggered from inside the collision area.)

In this case, I'm looking to have the players press their activate key while standing on certain floor locations to trigger scripts. Maybe I can rig this up with a combination of the above, and an AreaTrigger that activates/deactivates the invisible doodads collision when a player enters or all players exit the shape. It wouldn't be prefect, but might get a similar effect in the end.

Amran

  • Posts: 20
  • Maggot Crusher.
    • View Profile
Re: Triggering Scripts When Player Hits Activate
« Reply #4 on: February 01, 2014, 09:32:57 PM »
[Edit] Found it! It's based on the max width field found in ShowSpeechBubble scripts.

I may as well add another question while I'm at it! When using ShowSpeechBubble scripts, is there a way to add a line break to text? I noticed that entering something and using normal_speech doesn't cause it to wrap around, and instead leaves you with a very long speech bubble.
« Last Edit: February 04, 2014, 04:00:46 AM by Amran »

Hipshot

  • Developer
  • Posts: 455
  • Level Designer
    • View Profile
Re: Triggering Scripts When Player Hits Activate
« Reply #5 on: April 20, 2014, 11:51:02 AM »
Yes, there is now. With \n, like below.

Code: [Select]
Hello\nHello Again
« Last Edit: April 20, 2014, 12:20:28 PM by Hipshot »

Feaw

  • Posts: 18
  • Maggot Crusher.
    • View Profile
Re: Triggering Scripts When Player Hits Activate
« Reply #6 on: October 25, 2014, 08:37:12 AM »
\n Doesn't seem to add a new line for me... I worked around it with max bubble width and adding spaces for spacing, but it's a bit tedious...