Koding Konversation: Sword wielding wolf

This conversation is taken from the Project Spark Forum via The Wayback Machine
Date: 8 May 2016

OP: The Sh0tgun D0g
Okay basically in my RPG I’m making a wolf as the main char. One that has the capability of wielding a sword. My question is I have the sword in his mouth (the hilt of the sword) I want to attack and basically while the wolf does his default attack the sword rotates and etc. To give a swinging effect. Is that possible with koding? Or is that something that can’t be done since its during the attack animation?


Project Sparker: Try attaching again to the wolf, and try attaching to the mouth or head socket. When the wolf attacks, the sword follows perfectly and looks really nice. I can’t remember which socket I tried, but I am sure it was one of those two.

The Sh0tgun d0g: I believe I know what you are mentioning for if I am correct in my suspicion it’s what I’ve already done. The sword acts as it should following his movements perfectly, my goal is to add slight rotation to the sword to change its position making it seem like he’s actually slashing with it. (Currently it’s only an actual “slash” with his charge spin move, otherwise he’s just using the butt of the hilt (forgot the term) moreso than the actual blade.) I presume it may be possible by koding and having it change etc. Vertices with added rotation etc. Idk. But Idk if it can be done. I’m not really asking how to do it (Atleast not yet I love to try and figure this stuff out on my own.) Just a yes or no to if it’s possible.

Also the reason I haven’t tried yet is I’m more focused on the actual needs to my game, rather than the prettiness of it. So it’s a question for future reasons.

Brasten: What you’ll want to do is create a Page in the Wolf’s brain that controls the how the sword gets angled. You can have the sword (or any weapon object you wish) include a line of Kode…

WHEN: [interacted], DO: [it][ObjVar: my weapon] = [me]


WHEN [started to][attached], DO: [owner][ObjVar: my weapon] = [me]

This sets an Object Variable inside the object that interacted with/picked up/attached to the weapon. From there in the owning (wolf) brain, you make a Page dedicated to controlling how the weapon’s direction vectors get adjusted as the wolf attacks. A basic example would be…

WHEN [attacking], DO: [ObjVar: my weapon][pitch][2]

Which causes the sword to rotate clockwise around its X axis (kinda down and forward).

Doing this will require real work on your part. You will either need to learn how Object Space position and vectors work, to track head/mouth socket position relative to the center socket. Or study (using Pace) the timing for the head swings during an Attack animation, and time out the weapon rotation.

Do not put the movement Kode in the sword itself. There is a bug related to Attachments and Movement tiles that will cause the sword to lag a bit in direction and position. Control the sword’s movement from the Wolf’s brain by Object Variable reference.

MindcraftMax: To add to what Brasten said, don’t forget that you can find information on vectors in the Vectors guide, that could be useful if you need to control the movement/tilting of an object manually.

(By the way, butt of the hilt -> pommel)

Comments are closed.

Powered by WordPress.com.

Up ↑

%d bloggers like this: