Frictional Games Forum (read-only)

Full Version: Shake Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there, I was working on a custom story and I was wondering how I would make the screen shake, sort of like when the shadow roars. I used the wiki and made this code, however, it doesn't work when run. Any suggestions would be really appreciated. Here's what I've got so far:

PHP Code:
void OnStart()
{
    
AddUseItemCallback("OpenDoor""librarykey""level_wood_3""UnlockLevelDoor"true);
    
AddEntityCollideCallback("Player""PlayerCollide""ShakeFunction"true1); 
}
void OnEnter()
{
    
PlayMusic("02_amb_safe.ogg"true0.91.01true);
}
void OnLeave()
{
    
StopMusic(1);
}
void UnlockLevelDoor(string &in itemstring &in entity)
{
    
SetLevelDoorLocked(entityfalse);
    
AddPlayerSanity(100);
    
RemoveItem("librarykey");
    
CompleteQuest("""LibraryDoorQuest");
}
void memento(string &in asEntity)
{
    
AddQuest("""LibraryDoorQuest");
}
void ShakeFunction()
{
    
StartScreenShake(1,2,1,4);

The reason it's not working is because you're not calling the function "ShakeFunction" anywhere.

IGNORE THIS! READ MUDBILL'S ANSWER INSTEAD

Spoiler below!

If that's not calling, nothing inside it will call either.
Question is: When do you want the shake to start?


We can quickly make it start by making ShakeFunction into a timer.
PHP Code:
void OnStart()
{
AddTimer(""4"ShakeFunction");
}

void ShakeFunction(string &in asTimer)
{
StartScreenShake(1,2,1,4);


I hope you understand.

Because your ShakeFunction is a collision callback, you need the proper parameters to match, or else it's not recognized. This is written in the syntax below the collide function on the script page.

PHP Code:
void ShakeFunction(string &in asParentstring &in asChildint alState
(09-23-2014, 07:07 AM)Mudbill Wrote: [ -> ]Because your ShakeFunction is a collision callback, you need the proper parameters to match, or else it's not recognized. This is written in the syntax below the collide function on the script page.

PHP Code:
void ShakeFunction(string &in asParentstring &in asChildint alState

Oh right! haha I didn't see that it was a collision callback! Good catch Wink
^
Hehe, I almost feel like I'm competing with you here these days xD