Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shake Function
Carlos2295 Offline
Junior Member

Posts: 16
Threads: 5
Joined: Sep 2014
Reputation: 0
#1
Shake Function

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: (Select All)
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);

(This post was last modified: 09-23-2014, 05:33 AM by Carlos2295.)
09-23-2014, 05:33 AM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Shake Function

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: (Select All)
void OnStart()
{
AddTimer(""4"ShakeFunction");
}

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


I hope you understand.


Trying is the first step to success.
(This post was last modified: 09-23-2014, 07:47 AM by FlawlessHappiness.)
09-23-2014, 07:06 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#3
RE: Shake Function

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: (Select All)
void ShakeFunction(string &in asParentstring &in asChildint alState

09-23-2014, 07:07 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: Shake Function

(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: (Select All)
void ShakeFunction(string &in asParentstring &in asChildint alState

Oh right! haha I didn't see that it was a collision callback! Good catch Wink

Trying is the first step to success.
09-23-2014, 07:44 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: Shake Function

^
Hehe, I almost feel like I'm competing with you here these days xD

09-23-2014, 08:00 AM
Find




Users browsing this thread: 2 Guest(s)