Frictional Games Forum (read-only)

Full Version: Throwing entity at other entity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, hopefully this is a simple question.

I want to have the player break a pipe by throwing a rock or other heavy object at it. The player will throw the object at the pipe, and then a script will be triggered.

How would I go about doing this?

Thanks.
Did you already search the forums for this answer?

If I recall, the throwing function is already built into the game. Are you, instead, asking about how to script?
Add entity collide callback for the rock + a small script area over the pipe (make sure its large enough so a portion of the rock can go inside it). Remember the callback syntax for collide callbacks is:

(string &in asParent, string &in asChild, int alState)

Hope that helped.
So, make a ScriptArea that fits the pipe.

Now:

Code:
void OnStart()
{
AddEntityCollideCallback("Rock", "ScriptArea_pipe", "CRASH", true, 1);
}

void CRASH (string &in asParent, string &in asChild, int alState)
{
////Do the crash effect. It can be:
SetEntityActive("Broken_pipe", true);
SetEntityActive("Pipe", false);
///Feel free to add particle effects and others
}
I assumed the collide function would trigger if the player just held the rock in the script area. Thanks!

Edit: Is it possible to make any object break the pipe, or do I have to specify which one(s)?
You have to specify the selected "entities" that can break the pipe.

I know Damascus has a script already in his "The Great Work" that will determine whether the player has thrown the rock hard enough to damage the object.
Ask him and I'm sure he can help you.
So I implemented the script, but it triggers even when the player walks up to the script area with the rock.
Quote:I know Damascus has a script already in his "The Great Work" that will
determine whether the player has thrown the rock hard enough to damage
the object.

Ask him and I'm sure he can help you.
I'm hesitant to take scripts from "The Great Work" but if that's my only option then I guess I'll ask him. I could have sworn the regular Amnesia had places like this where you have to throw an object to break something. How did those work?
(12-15-2012, 04:21 PM)ElectricRed Wrote: [ -> ]So I implemented the script, but it triggers even when the player walks up to the script area with the rock.
Quote:I know Damascus has a script already in his "The Great Work" that will
determine whether the player has thrown the rock hard enough to damage
the object.

Ask him and I'm sure he can help you.
I'm hesitant to take scripts from "The Great Work" but if that's my only option then I guess I'll ask him. I could have sworn the regular Amnesia had places like this where you have to throw an object to break something. How did those work?
Just don't take my animations and models and you'll be ok.

Damascus is a kind fellow, he might be able to help you with the throwing and breaking.
(12-15-2012, 04:24 PM)crisosphinx Wrote: [ -> ]
(12-15-2012, 04:21 PM)ElectricRed Wrote: [ -> ]So I implemented the script, but it triggers even when the player walks up to the script area with the rock.
Quote:I know Damascus has a script already in his "The Great Work" that will
determine whether the player has thrown the rock hard enough to damage
the object.

Ask him and I'm sure he can help you.
I'm hesitant to take scripts from "The Great Work" but if that's my only option then I guess I'll ask him. I could have sworn the regular Amnesia had places like this where you have to throw an object to break something. How did those work?
Just don't take my animations and models and you'll be ok.

Damascus is a kind fellow, he might be able to help you with the throwing and breaking.
Haha, I wouldn't dream of taking your models. Would this throwing script happen to be in the demo?
(12-15-2012, 04:31 PM)ElectricRed Wrote: [ -> ]
(12-15-2012, 04:24 PM)crisosphinx Wrote: [ -> ]
(12-15-2012, 04:21 PM)ElectricRed Wrote: [ -> ]So I implemented the script, but it triggers even when the player walks up to the script area with the rock.
Quote:I know Damascus has a script already in his "The Great Work" that will
determine whether the player has thrown the rock hard enough to damage
the object.

Ask him and I'm sure he can help you.
I'm hesitant to take scripts from "The Great Work" but if that's my only option then I guess I'll ask him. I could have sworn the regular Amnesia had places like this where you have to throw an object to break something. How did those work?
Just don't take my animations and models and you'll be ok.

Damascus is a kind fellow, he might be able to help you with the throwing and breaking.
Haha, I wouldn't dream of taking your models. Would this throwing script happen to be in the demo?
Just message Damascus. I have no idea, I'm an artist not a coder. :I

Here's his user... thingy. Smile http://www.frictionalgames.com/forum/user-20368.html