How to make a piano lid lift slowly - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: How to make a piano lid lift slowly (/thread-11925.html) |
How to make a piano lid lift slowly - Cryaotic - 12-18-2011 As of right now I have the lid opening upon interaction with an object, it opens all the way after a jerky movement which is all fine and good, though I was going for a slowly moving effect which seems quite challenging to come by. This is what I have currently: PHP Code: void pianocoverlift1(string &in asEntity){ if(GetLocalVarInt("LiftDone") != 1){ SetLocalVarFloat("LiftBuildUp", 0); AddTimer ("LiftingPiano", 0.50, "LiftingPiano1"); AddTimer ("PianoLiftStop", 4.5, "PianoLiftStopFunc");} else{ RemoveTimer("LiftingPiano"); }} Thank you kindly for any assistance! (also I have no idea how to make the format of the code look good on the forum, it's being weird for me) RE: How to make a piano lid lift slowly - Khyrpa - 12-18-2011 Well one thing that comes to mind would be to change the piano's type in the model editor from Lever to MoveObject and use SetMoveObjectState. I guess it would make the piano un- interactable though. Using something like you did there with lower values could make it seem more fluent. I would personally use ugly switch case function with a 100 cases, but thats just me. RE: How to make a piano lid lift slowly - Your Computer - 12-18-2011 Try using SetLeverStuckState instead of AddPropForce. (12-18-2011, 12:05 AM)Cryaotic Wrote: (also I have no idea how to make the format of the code look good on the forum, it's being weird for me) (Stop using the WYSIWYG editor of the forums.) RE: How to make a piano lid lift slowly - palistov - 12-18-2011 Try this: PHP Code: int pianoTick=0; This loop repeats very quickly to constantly be adding a small upwards force to the lid. You'll definitely have to tweak values to get it right since I have no idea what force values you'll need. Initiate it by using a timer with a duration of 0.01f, so it basically triggers instantly. Also, replace pianonamehere with your piano's name. Don't change the _BodyLid suffix, that designates the entity body to apply the force to. LATER EDIT: Well I was curious so I tried it out in-game. Doesn't work very well, even with a custom entity with modified properties. The reason being that the object has gravity so it just falls back down. It works for doors though. :3 I'll try more stuff later, I have a few ideas in mind. Ropes and stuff. RE: How to make a piano lid lift slowly - Apjjm - 12-18-2011 That approach should work if you make the timestep small enough. Try 0.0166f (1/60). RE: How to make a piano lid lift slowly - Your Computer - 12-18-2011 Unless i'm mistaken, SetLeverStuckState causes a smooth animation for the lever, so a looping timer is unnecessary. A value of -1 for the state should suffice. RE: How to make a piano lid lift slowly - palistov - 12-18-2011 @Apjjm - yeah I didn't try it with a very large range of values. Perhaps the step value of .02 was a little too long. @Your Computer - I tried using a looping timer to set the stuck state progressively higher, but the lid doesn't move at all when using that function -- I think it's only used for keeping the lever at a state once it has been reached. Maybe I'll give it another later, but there's always the option of separating the lid and piano meshes and using separate entities. That's usually the approach I take, but I didn't dig too deeply into the issue. RE: How to make a piano lid lift slowly - Cryaotic - 12-19-2011 (12-18-2011, 02:32 AM)Apjjm Wrote: That approach should work if you make the timestep small enough. Try 0.0166f (1/60).This one actually worked quite well! In the end I just changed the time between each loop to 0.0166f andthe force increase to .50 each loop - a really almost eerie effect because of how natural it does it. Thanks for all those that chipped in! Definitely worked great. :] |