How to "disable" gravity for an entity --EASY TUT-- - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: How to "disable" gravity for an entity --EASY TUT-- (/thread-4922.html) |
How to "disable" gravity for an entity --EASY TUT-- - Frontcannon - 10-04-2010 Hello! This is a quick and surprisingly easy trick I discovered when playing with timer functions. It makes objects seems to have no real weight and bounce off the walls and even hover a bit! #1 First, create a simple room in the editor and save the map. It needs to have some movable entities, in my case the books and the skull. #2 Create a .hps file with the name of the map and add the "default" script (I removed the if clause): Code: //////////////////////////// #3 Now it gets interesting! You can make a script area in the editor but I just put my stuff in OnStart(), no areas needed. Add a timer in OnStart(), which should look like this: Code: //////////////////////////// #4 Even more interesting! This is where the magic is at.. I want you to make the function the timer calls and it has to contain these lines: Code: void FloatObjects(string &in asTimer) So, what does it do? The coders here may know already, but for everybody else, it's really simple: The AddPropImpulse adds, like the name says, a specified impulse to the object. The three numbers are the x, y, z coordinates the impulse goes to, in this case we have a very weak impulse going to the y direction, that means UP! The AddTimer is another timer that calls itself, creating a loop. 0.01 means the time between those calls, it is very short so the player doesn't notice all the little "bounces". The force you specify makes for very interesting applications, I haven't tested it with bigger objects, but for small stuff everything greater than 0.2 makes the object float upwards. Numbers like 5 make it really fight the ceiling, kinda creepy.. just test what works best for you! I hope you had fun reading this and trying it out Credits to Jens for the idea! RE: How to "disable" gravity for an entity --EASY TUT-- - HakePT - 10-05-2010 Frontcannon and Jens I proudly present you with... THE INTERNET! Congratulations this is some awesome stuff that i may or not end up stealing! If i do use this i will place your name in the credits for all internet to see RE: How to "disable" gravity for an entity --EASY TUT-- - Frontcannon - 10-05-2010 Thanks, I will add this to the wiki, we need more beginner script tutorials The Wiki Tutorial has been added! Go check it out! |