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
Hammer animation
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#1
Hammer animation

I would like to get the hammer to move as i use it on an entity, like it does in the actual game. I looked at the code in the actual game, and it uses "SetMoveObjectState".
The problem with this is that it makes the hammer move only vertically up or down, whereas i want the hammer to hit something on the wall.
So I was wondering, how do you make the hammer move horizontally using scripts ( i think "stone_hammer_move" is a static entity so i cant use AddPropForce )

Also, in the level Editor i found a setting, "AngularOffsetArea -- When mode is angular, this is the point it rotates around"
How do i make mode angular, and would this enable the hammer to swing like i want it to?

If anyone can help i would appreciate it, Thanks!

07-12-2011, 12:05 AM
Find
Roenlond Offline
Senior Member

Posts: 331
Threads: 3
Joined: Apr 2011
Reputation: 0
#2
RE: Hammer animation

Probably not the most efficient way of doing it, but here's my script.

void OnStart()
{
AddUseItemCallback("breaklock", "stone_hammer_chipper", "padlock_1", "BreakLock", true);
}

void BreakLock(string &in asItem, string &in asEntity)
{
SetEntityActive("stone_hammer_move_1", true);
SetEntityActive("stone_chipper_move_1", true);
CreateParticleSystemAtEntity("cloud", "ps_dust_drilling.ps", "padlock_1", false);
CreateParticleSystemAtEntity("cloud", "ps_enemy_disappear_per_bone_small.ps", "padlock_1", false);
AddTimer("removelock", 0.7f, "RemoveLock");
AddTimer("bangbang", 0.2f, "bangbang");
AddTimer("removehammer", 0.8f, "removehammer");
SetMoveObjectState("stone_hammer_move_1", 0.2f);
SetMoveObjectState("stone_chipper_move_1", 0.2f);
PlayGuiSound("15_hammer1.ogg", 1);
CompleteQuest("opencellar", "OpenCellar");
}

void RemoveLock(string &in asTimer)
{
SetPropActiveAndFade("padlock_1", false, 1.0f);
SetSwingDoorLocked("CellarToWaterPart", false, true);
CreateParticleSystemAtEntity("hit", "ps_hit_metal.ps", "padlock_1", false);
CreateParticleSystemAtEntity("dust", "ps_break_wood_pulley_blocker.ps", "padlock_1", false);
}

void bangbang (string &in asTimer)
{
SetMoveObjectState("stone_hammer_move_1", -0.2f);
SetMoveObjectState("stone_chipper_move_1", -0.2f);
PlayGuiSound("15_hammer2.ogg", 1);
}

Various timers run commands at different times and plays sounds to "break" the lock. Some particles make it more realistic. There's probably a better way to do it, but I couldn't find any information about it so I experimented with it and my result looks nice Smile
07-12-2011, 12:50 AM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#3
RE: Hammer animation

Thanks for trying to help me, but this didn't work Sad , it's the SetMoveObjectState command, it only seems to let me move my object vertically in the y axis, there is no option to let it move in the x or z axis, so i have no way of making the hammer move forwards/backwards, SetMoveObjectState only moves up/down. I hope you understand what i'm trying to say? does anyone else have any suggestion on how i can get the hammer to move properly? or can anyone answer my other questions above? please help, thanks in advance Smile

07-12-2011, 10:38 PM
Find
Roenlond Offline
Senior Member

Posts: 331
Threads: 3
Joined: Apr 2011
Reputation: 0
#4
RE: Hammer animation

Yeah, it worked like you were saying on my custom story. It looked as if you banged the chipper on the padlock.
07-12-2011, 10:47 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#5
RE: Hammer animation

Yeah im glad you understand, the problem with me is that im not using the hammer on a padlock - the padlock is angled slighty, so downwards motion can still hit it.

Im using my hammer on a flat wall section, with no parts that it can hit if it just moves down, so the hammer just floats, moving up and down, hitting nothing... very annoying.

07-12-2011, 10:51 PM
Find
Roenlond Offline
Senior Member

Posts: 331
Threads: 3
Joined: Apr 2011
Reputation: 0
#6
RE: Hammer animation

That is very odd indeed, I'm not entirely sure what could be causing it. Perhaps mine works because it's tilted somewhat? You're using the _move hammer, right?
07-12-2011, 10:58 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#7
RE: Hammer animation

yep, the only difference between my script and yours, is that i'm not using the chipper at all
edit, also, i tried mine tilted, still no luck..

(This post was last modified: 07-12-2011, 11:05 PM by DRedshot.)
07-12-2011, 11:05 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#8
RE: Hammer animation

Why not have the player hold a hammer and bang it on whatever you're trying to bang it on. In my custom story demo that I released, I had the player find a rather large hammer and take it and, by themselves, bang it on a rusty lock to break it off so they could open the door. It is really cool that you could have the normal objects around you to be used for puzzles and stuff. It definately makes it more immersive. Smile

07-12-2011, 11:09 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#9
RE: Hammer animation

Actually, i deleted something in the entity tab of my hammer in the editor
(It was the thing in AngularOffsetArea) and now it seems to be behaving itself. It seems illogical to me that it now rotates when I Disable AngularOffsetArea, because i thought if I enabled it, it would act as a hinge...... Anyways, thanks a lot for your help, I can Finally continue with my custom story! Smile

Edit: just read your post kyle and it seems like a very cool idea i might do that actually, even after spending all day getting this script to work Smile)

(This post was last modified: 07-12-2011, 11:13 PM by DRedshot.)
07-12-2011, 11:12 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#10
RE: Hammer animation

ok, sorry about this but i think i have found some sort of bug.
The animation script works great! the particles show up, the hammer swings, sounds play etc..,

But as soon as I press F5 and quickload, the hammer glitches into the wall, flies up to the ceiling and causes havoc! The problem is stopped consistantly everytime i click Quick Map Reload, and occurs again if I quickload... This has happened 5 times in a row, has anyone else ever had this problem?

07-13-2011, 12:25 AM
Find




Users browsing this thread: 1 Guest(s)