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
How would you make a mechanic where you can hide under a bed?
GeneralCAL Offline
Junior Member

Posts: 12
Threads: 3
Joined: Jun 2014
Reputation: 0
#5
RE: How would you make a mechanic where you can hide under a bed?

(07-04-2014, 07:09 PM)Mudbill Wrote: To make the non-collideable bed, open the bed entity in the Model Editor, and uncheck CollidePlayer after selecting the body. Save as a different name (for example bed_nocollide).

Place both beds in the same place, but keep the nocollide version inactive. Add a script area where you want the player to be able to click to hide, then go on the Entity tab of that area and write a function name in the PlayerInteractCallback box. Also uncheck the AutoRemove box.

Jump to your script and add the callback:
PHP Code: (Select All)
void InteractBed(string &in asEntity)
{
    If(
GetLocalVarInt("IsHiding") == 0) {
        
    }
    else {
        
    }


This variable I added is just IF the player is able to interact with the same area while hiding under the bed. If not, you can add another area where the player is hiding that they can click, which will run the same function (here named InteractBed but can be anything).

Inside the IsHiding = 0 block, add the scripts you want to run when the player will hide. This will probably be TeleportPlayer("PlayerStartArea"); and MovePlayerHeadPos(1, 0.2, 1, 10, 3); but I suggest you use a FadeOut and FadeIn effect in between to make it more smooth. Also add SetPlayerMoveSpeedMul(0); and SetPlayerRunSpeedMul(0); Don't forget to also switch between the entities, using SetEntityActive("normal_bed", false); and SetEntityActive("bed_nocollide", true);

Inside the else block, restore the player's position. Teleport them to another start area beside the bed, and reset the values. MovePlayerHeadPos(1, 1, 1, 10, 3); and SetPlayerMoveSpeedMul(1); + SetPlayerRunSpeedMul(1); Also switch the entities back by doing the same as before, just inverted.

Thanks a bunch, Mudbill! I hope this works! (I probably won't be able to test it for a couple weeks, tho. Also, what program do you recommend I download to allow me to download .zip files and .rar files, because my computer wont let me and I don't know how to work 7-Zip... D:
(This post was last modified: 07-04-2014, 07:17 PM by GeneralCAL.)
07-04-2014, 07:16 PM
Find


Messages In This Thread
RE: How would you make a mechanic where you can hide under a bed? - by GeneralCAL - 07-04-2014, 07:16 PM



Users browsing this thread: 1 Guest(s)