Monster animation and movement : Strafe left & right

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Vandalar
Posts: 31
Joined: Sun Jan 18, 2015 6:05 pm
Location: Montreal, Canada

Monster animation and movement : Strafe left & right

Post by Vandalar »

Hello fellow modders,

Question : I want to force a monster to strafe left or right when I tell it to (by using a modified onThink hook, calling a fonction in a script entity). How can I accomplish that ?

Context : Me and one of my friend, created a new monster from scratch, modelling and animations. Almost everything works fine : moving forward, turning left and right, different attack animations. It's using the UggardianBrain with some modifications with the onThink hook.

The new monster is almost finished, but there is one thing I didn't manage to make it work : strafing left and right. I checked the others monsters definitions and while they do strafe in game, they only have the two animations definitions for "strafing" and nothing else, beside the MonsterMove component.

I checked the scripting reference (and JKos doc) for the MonsterMoveComponent and found setStrafeRightAnimation (or left) and setStrafeLeft, but I don't know how to use them properly. The first one take a string as an argument, but what string exactly ? The animation name ? The path of the animation ? I tried severals things, but I got an "invalid component" in the editor or "attempt to call a nil value".

Do I need to create two other MonsterMove components in my monster definition with the above method/property ?

The second one takes a boolean. Do I need to put this value at true at runtime when I want to force it to move ?

Code: Select all

animations = {
				idle = "mod_assets/animations/deathSkullIdle.fbx",
				moveForward = "mod_assets/animations/deathSkullMoveForward.fbx",
				strafeLeft = "mod_assets/animations/deathSkullStrafeLeft.fbx",
				strafeRight = "mod_assets/animations/deathSkullStrafeRight.fbx",
[...]
I tried to define another Move component, but as I mentionned, it didn't work out. Maybe I'm missing a property or not using the right one ?

Code: Select all

		{
			class = "MonsterMove",
			name = "strafeLeft",
			sound = "medusa_walk",
			cooldown = 0,
			animationSpeed = 1.6,
			strafeLeft=true,
			strafeLeftAnimation = "strafeLeft",
		},
Since the other MonsterMove component of the base campaign have one component, I'm obviously not on the right track.

Can someone shed some light ?

Thanks in advance,

Vand
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Monster animation and movement : Strafe left & right

Post by minmay »

You don't need to add extra components for strafing. The monster should do it automatically if you have strafeLeft and strafeRight animations. Perhaps your custom brain never actually strafes? The monster won't strafe if it's already performing another action, or if the square to strafe into is blocked.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Vandalar
Posts: 31
Joined: Sun Jan 18, 2015 6:05 pm
Location: Montreal, Canada

Re: Monster animation and movement : Strafe left & right

Post by Vandalar »

Thanks for the info. I went back to check my custom brain, and I "face-palmed" myself. I noticed it didn't finish with a "false" (reference to Petri's post viewtopic.php?f=22&t=9919&p=95608&hilit ... ain#p95608), so it didn't go back to the built-in brain.

My monster now strafe left and right like it should, so I don't need to force it to strafe anymore.

Regards,

Vand
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Monster animation and movement : Strafe left & right

Post by kelly1111 »

Very interrested in seeing your monster in action !
Post Reply