Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //From my Amnesia Rebirth Tutorial Series
- //Episode 33 Puzzles Pt.1! Breaking Doors!
- //https://www.youtube.com/playlist?list=PL4KkjlmOwLwwMVqedCNpi6caUxhgyf8Qr
- //-----------------------------------------------------------
- ///////////////////////////////////////////////////
- // Functions used in today's episode
- //////////////////////////////////////////////////
- //Make sure you include the prop helper functions at the top of your script
- #include "helpers/helper_props.hps"
- //Get the entity object of an entity using it's name
- Map_GetEntity("hammer_1");
- //entityName (String)- the name of the entity as it appears in your level editor.
- //Assuming we save the entity object to a variable called pEnt...
- iLuxEntity@ pEnt = Map_GetEntity("hammer_1");
- //Gets the physics body object attached to the entity
- pEnt.GetMainBody()
- //Gets the linear velocity that the physics body is applying to entity as a cVector3f object
- pEnt.GetMainBody().GetLinearVelocity();
- //Saves the above vector to a variable we decided to call hammerVelocity
- cVector3f hammerVelocity = pEnt.GetMainBody().GetLinearVelocity();
- //Gets the x, y and z velocities from our vector above
- hammerVelocity.x
- hammerVelocity.y
- hammerVelocity.z
- //Changes our decimal number (our float) into a string so that we can print it
- cString_ToString(hammerVelocity.x);
- //floatNumber (float)- the number you wish to convert into a string
- //The next 2 values below are optional
- //decimalPlaces (int)- the number of decimal places you want to capture
- //removeZeros (bool)- should zeros be removed from the end of the number (true or false).
- //Set the health of an object/prop to something else
- Prop_SetHealth("door_1", 0.f);
- //propName (String)- the name of the object/prop as it appears in your level editor
- //health (float)- the health that the prop should be set to.
- //Deletes an entity from the map (cannot be recreated, use Entity_SetActive(false) if you plan to make the object reappear)
- Entity_Destroy("hammer_1");
- //entityName (String)- the name of the entity as it appears in your level editor.
- ///////////////////////////////////////////////////
- // Entire callback we wrote in today's episode
- //////////////////////////////////////////////////
- bool OnCollide_HammerBreakArea(const tString &in asParent, const tString &in asChild, int alState)
- {
- if(alState == 1){
- if(asChild == "hammer_1" && Player_IsInteracting()){
- iLuxEntity@ pEnt = Map_GetEntity("hammer_1");
- cVector3f hammerVelocity = pEnt.GetMainBody().GetLinearVelocity();
- cLux_AddDebugMessage(cString_ToString(hammerVelocity.x));
- cLux_AddDebugMessage(cString_ToString(hammerVelocity.y));
- cLux_AddDebugMessage(cString_ToString(hammerVelocity.z));
- if(hammerVelocity.z > 4.0f){
- Prop_SetHealth("door_1", 0.f);
- Entity_Destroy("hammer_1");
- return false;
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement