Creating animated objects on interaction - Tutorial
Apr 2, 2020 9:16:25 GMT -5
Bakie, jwofles, and 20 more like this
Post by Aurora Kreativ on Apr 2, 2020 9:16:25 GMT -5
What this tutorial covers
This tutorial will cover how to make a non-animated object animate between different animation states on interaction, in which the object will stay in a certain state after it’s done animating, by using Sims 4 Studio and Blender. By that I mean, how to make an actual object animate, and not a sim.
This is an intermediate tutorial and best suited for those who have worked with Sims 4 Studio for a while and have some knowledge on using Blender.
I will however explain some things like what different tunings are/mean for those who may have worked with them before but may not really know how they work. I also will go into how to rig and animate an object in Blender.
If you are someone who knows most of these things already, you may find it annoying to read. You can skip the explanation parts in this tutorial and go straight to the “doing” part. I have done my best to separate some of the explanatory parts by marking them as "quotes". They have white backgrounds to them.
I will however explain some things like what different tunings are/mean for those who may have worked with them before but may not really know how they work. I also will go into how to rig and animate an object in Blender.
If you are someone who knows most of these things already, you may find it annoying to read. You can skip the explanation parts in this tutorial and go straight to the “doing” part. I have done my best to separate some of the explanatory parts by marking them as "quotes". They have white backgrounds to them.
They will look like this!
The tutorial will work by taking an existing in-game purely decorative object as it is and making it animate, or by overriding an existing decorative object with a new mesh and animating that.
This tutorial will NOT cover how to edit or add more animation to an object that already has animations to it.
Below is an outline of what we want to try accomplishing with this tutorial.
This tutorial will NOT cover how to edit or add more animation to an object that already has animations to it.
Below is an outline of what we want to try accomplishing with this tutorial.
Tutorial goal
Step 1 – Creating the base object
2.1 Object Tuning
- You click on the object and an interaction shows up.
- You click the interaction and the object animates in some way.
- The object stops animating at the end of its animation and stays that way.
- You click the object again, and now another interaction shows up.
- You click on this new interaction, the object animates in a different way, and at the end of the animation, the object stays that way.
Where to start off
First, you will want to have a few things clear to yourself.
First, you will want to have a few things clear to yourself.
- How will the object animate? Will the whole object animate or only parts of it?
- Where will the object sit? Ex: on the wall, ground, table, hang from the ceiling etc.
The finished look
Below you can see a .gif of what the finished product looks like for this tutorial before you get started. 😊
Step 1 – Creating the base object
In my example, I want to make a pair of window curtains that will animate opening and closing on interaction so that the curtains can both let in light and block it out based on what you choose.
I want to use an already existing object in game, namely the “Flaunting Flounces Panels” and make it animate. So, I’ll choose in Sims 4 Studio “Create 3D mesh” and then choose this object to work on.
I want to use an already existing object in game, namely the “Flaunting Flounces Panels” and make it animate. So, I’ll choose in Sims 4 Studio “Create 3D mesh” and then choose this object to work on.
However, this type of object only has one mesh which has the cut number of 0 and doesn’t have any shadow plane which usually has the cut number 0. For some reason, the object’s mesh must have a cut number larger than 0 in order to be able to animate in game.
So in order for the animations to work, I will have to choose another object that has the main mesh with a higher cut number than 0 as a base for the curtains. I have not successfully found anything that would contradict this statement when I have done tests, however, if you have knowledge about this and think this is inaccurate, feel free to post a response below. Thanks!
So, since my object should sit on a wall, I will look for a base object that sits on a wall and has a mesh with the cut number of 1. I went with “The Pianist” painting object which has a shadow plane with cut number 0 and the main object mesh with a cut number of 1.
So, what I will do is to make a package with this painting object as my base, then create a new package with the curtains, and then later on extract the curtains mesh and add it to the painting mesh. Pretty standard stuff.
However, if you want to work with an object that already has a cut number higher than 0, then you don’t have to use another base object of course.
Once you have found something that sits the way you want it to (on the wall, or the floor, or the ceiling, or a table etc.) as a base and has the main object mesh cut number larger than 0, you can continue with the tutorial below.
So, what I will do is to make a package with this painting object as my base, then create a new package with the curtains, and then later on extract the curtains mesh and add it to the painting mesh. Pretty standard stuff.
However, if you want to work with an object that already has a cut number higher than 0, then you don’t have to use another base object of course.
Once you have found something that sits the way you want it to (on the wall, or the floor, or the ceiling, or a table etc.) as a base and has the main object mesh cut number larger than 0, you can continue with the tutorial below.
Step 2 – Object tuning, Object state tunings and Interaction tunings
Now you want to start creating some tunings for this object.
The tunings are, essentially, different files that defines/tunes different things related to the object. In this tutorial, you will need to create three different types of tunings that will “tune” the object to work the way you want it to. These different types of tunings are called “Object tuning”, “Object state tuning” and “Interaction tuning”. As you can tell by the names of these, they tune different things regarding the object.
The tunings are, essentially, different files that defines/tunes different things related to the object. In this tutorial, you will need to create three different types of tunings that will “tune” the object to work the way you want it to. These different types of tunings are called “Object tuning”, “Object state tuning” and “Interaction tuning”. As you can tell by the names of these, they tune different things regarding the object.
2.1 Object Tuning
So, the first step is to extract an object tuning with Sims 4 Studios “Extract tuning” feature.
There are different object tunings that are paired with different objects available in the game. For example, a couch has an object tuning, a table has a different object tuning and a curtain has a different object tuning.
If you are working with, let’s say, a couch object, then it would make sense that you would use an object tuning that is already paired with this object as it contains XML that defines this specific object. However, you could technically use any object tuning that you can find, even if it’s not for a couch.
If you are working with, let’s say, a couch object, then it would make sense that you would use an object tuning that is already paired with this object as it contains XML that defines this specific object. However, you could technically use any object tuning that you can find, even if it’s not for a couch.
“Why is that?” you may ask. “You just said earlier that every object is paired with an object tuning, how could you then just ‘pick one’”.
Well that is because every object tuning has the same basic markup/structure of XML that an object tuning needs in order to work. Then they have different extra parts of XML that defines things about the object in question. You can alter these files XML markup by adding or removing parts of XML, so it works differently for your object. This however requires that you know what to change in them, which is generally why you would go with something that works as closely to what you’re trying to create.
Please do note that certain objects in game uses other types of tunings than object tunings. Like doors for example, they use door tunings instead.
Simplest thing to do to get an object tuning for your object, is just to pick the one that is already paired with the base object.
To find the object tuning that your base object is using, go to the “Object definition” in the Warehouse tab and scroll down until you find “Tuning id”. Just copy that code and paste it into the “Extract tuning” filter area, then select it and add it to the package.
Simplest thing to do to get an object tuning for your object, is just to pick the one that is already paired with the base object.
To find the object tuning that your base object is using, go to the “Object definition” in the Warehouse tab and scroll down until you find “Tuning id”. Just copy that code and paste it into the “Extract tuning” filter area, then select it and add it to the package.
In my case, I’ll extract the curtains object tuning file and add it to the package instead of the painting’s.
After that is done, you want to continue with the other tunings.
2.2 Object state tunings
An object state tuning defines the states that the object can be in. If we, as an example, take a real-world object like a door, it can be in the state of “opened” and it can be in the state of “closed”. It can also be in the state of “broken” and “functional” etc.
In terms of our object, we can add different states to it that we want it to be in after an interaction has taken place with it.
For my curtains, I want it to be able to be in an “open” state and a “closed” state. So, I’ll want to add two state tunings to my package to alter in accordance with my needs.
One that I like to use, is that which is paired with the ceiling fan object in Sims 4 and is available in the base game. It has two states available which is “on” and “off”. To find them, go to “extract tuning” and type in the filter area “object_state/ceilingFan”.
One that I like to use, is that which is paired with the ceiling fan object in Sims 4 and is available in the base game. It has two states available which is “on” and “off”. To find them, go to “extract tuning” and type in the filter area “object_state/ceilingFan”.
You’ll see that there are three tunings showing up that are all the type “object state”. Two of these are the state tunings that define different things about their states, and the third one is basically a list that references these states.
I’m guessing the game needs the list as a reference point, to see which states are available to the object. So, the game basically looks at the list and goes, “Ah, this object uses these states, one with the key x and one with key y, let’s look for these states”. Since we have the two states available in our package, it will find them and use them correctly by referencing this list. That’s my theory anyway from a programmer perspective.
I will add all these three to the package.
Now you may be thinking that you need more states for your specific object. You technically only need to add one via the “Extract tuning” feature, because you can add more later by duplicating the one you added and then change it.
More on that later. For now, you can add these to your object package.
Now you may be thinking that you need more states for your specific object. You technically only need to add one via the “Extract tuning” feature, because you can add more later by duplicating the one you added and then change it.
More on that later. For now, you can add these to your object package.
2.3 Interaction tunings
Now that we have that done, we can go ahead and add some interaction tunings.
An interaction tuning tells the game about an interaction that is available to the object. In this tuning, you specify the text of the interaction that should show up in game. It also regulates what states the object should be in after you interacted with it as well as certain outcomes of what should happen next after the interaction. There are other things as well you can specify in this interaction tuning, and we'll look into some later on. However, I will only go through the basics of what we need for our animated object and nothing else.
Now, there are different types of interaction tunings available. They all work in different ways and making them work needs adjustments with regards to their specific “rules”.
For example, there’s a type of interaction called “SuperInteraction” as well as “ImmediateSuperInteraction”. There are other interaction types available as well, but when it comes to interacting with an object, these two are the most common.
For example, there’s a type of interaction called “SuperInteraction” as well as “ImmediateSuperInteraction”. There are other interaction types available as well, but when it comes to interacting with an object, these two are the most common.
The way I understand the “ImmediateSuperInteraction”, is that it makes the interaction happen immediately, as indicated by its name. This basically means, that as soon as you choose an interaction in game that is based on this, whatever happens afterwards happens immediately instead of waiting for something else to happen first, such as, waiting for the sim to walk up to the object for example. If this isn't entirely correct and you have more knowledge about this, you may add what you know about it in a response below.
The ceiling fan object also has an interaction tuning available you can use. This one is based on the type “ImmediateSuperInteraction”. It makes sense, since whenever we turn the ceiling fan on and off in game, it happens immediately.
We’re going to be using the “ImmediateSuperInteraction” for this tutorial.
For that, you can extract the ceiling fans interaction. You can find it by simply searching for “ceilingFan”. It will pop up with some of the other tunings available for this object.
Now you have added all the files necessary to make the object have an interaction available to it.
Let’s go to the next step.
2.4 Renaming tunings and adding more as needed
Now you will want to start renaming these tunings. If you don’t do this, these tunings may interfere with the other objects in game that uses them, not just your object.
To rename a tuning you have added, you will want to select it and go to the Data tab instead of the XML tab. In there, you’ll see “Name” and “TuningId”. You’ll need to make sure both are changed to be unique from any other object, so that they don’t clash.
To rename a tuning you have added, you will want to select it and go to the Data tab instead of the XML tab. In there, you’ll see “Name” and “TuningId”. You’ll need to make sure both are changed to be unique from any other object, so that they don’t clash.
To do so, remove the text that is present in the name field, and type in a new name. For this, I recommend you use a naming convention like this: “YourName:yourObject-tuningType”. Note that after the “YourName” part, there’s a colon. When you add a colon at any part of the name of the tuning, Sims 4 Studio will automatically generate a new tuning id in the “TuningId” field, so you don’t have to. This tuning id and name are now matched to this specific tuning file only, since it has a unique name.
So in my case, I’m going to add: “AuroraKreativ:AnimatedCurtains-objectTuning” for the object tuning file.
Then for the object state tunings, I’ll name them like this: “AuroraKreativ:AnimatedCurtains-OpenedState” and “AuroraKreativ:AnimatedCurtains-ClosedState”. Then I’ll name the object state list to “AuroraKreativ:AnimatedCurtains-States” and the interaction tuning to “AuroraKreativ:AnimatedCurtains-Open”.
I recommend you name yours in a similar way that makes it easy for you to tell which tuning is which.
The last thing we will want to do is to change the Object Definition’s name and instance key. You only really need to change the instance key for this, but I generally think it looks better with a shorter name as well so let’s change both.
For the name, you can just change the name to your liking. You don’t need to use colon in the name here as this isn’t a tuning file, but for consistency with all the other names, you may as well add it. I’ll name mine “AuroraKreativ:AnimatedCurtains”.
For the instance key, you can copy the name and paste it into the Hash Generator and then copy the FNV64 value and paste it into the "Instance" field.
For the instance key, you can copy the name and paste it into the Hash Generator and then copy the FNV64 value and paste it into the "Instance" field.
IMPORTANT EDIT! You want the instance key to start with a letter for it to work apparently, so if yours don't automatically get a letter as the first character in the FNV64 field, then tick the High Bit checkbox in the Hash Generator to make sure it starts with a letter. If it starts with a number, it seems it might not work in game as the object will display a red X thumbnail and can't be placed.
The last step to this is very important. You need to add this instance key to the Object Catalog’s instance field as well, as they must match for it to work properly.
Now your object should be quite unique indeed.
Now your object should be quite unique indeed.
2.5 Adding more states and interactions
At this point, it’s a good idea to add more object states and interaction tunings as needed. Let’s say you want more object states. In that case, you can duplicate one of the existing states you have already added. However, to do this, you need to change the instance key of the duplicated tuning so the game and Sims 4 Studio can differentiate between the tunings.
So, before you hit the “Duplicate” button, you will want to hash a new instance key. This you can do by going to “Tools” in the menu bar and selecting “Hash Generator”. With this tool, you will want to add the name of the tuning in the “text” field, and it will generate different types of hashed values for you based on this text. Use the same naming convention as you did before.
Since you want a new object state tuning, you want to name it the same way you did for the other states. For example “YourName:YourObject-State”. Then you will want to copy the “FNV64” field value and then close the hash generator.
Now you can select one of your other states and click on the button “Duplicate”. This will open another window where you will want to add the new instance key to. Once you have pasted it in, click save. Then you’ll see how the new tuning was added to the bottom of the list with the new instance key value.
Don’t forget that you now need to change the name of this new tuning in its name field, so it’s not the same as the one you duplicated.
Do the same with interactions if you want more of them as well.
Since you want a new object state tuning, you want to name it the same way you did for the other states. For example “YourName:YourObject-State”. Then you will want to copy the “FNV64” field value and then close the hash generator.
Now you can select one of your other states and click on the button “Duplicate”. This will open another window where you will want to add the new instance key to. Once you have pasted it in, click save. Then you’ll see how the new tuning was added to the bottom of the list with the new instance key value.
Don’t forget that you now need to change the name of this new tuning in its name field, so it’s not the same as the one you duplicated.
Do the same with interactions if you want more of them as well.
I added one new interaction to my package, as I want an open interaction and a close interaction.
Step 3 - Editing the tuning files
Now you have added all the necessary tuning files for your object to be interact-able.
Let’s get started editing these new tuning files for our object.
3.1 Object tuning editing
Select the object tuning, and view its XML tab. If you have never seen or worked with XML before, it may seem a bit daunting. You can read up about XML and how it works on W3C’s tutorial on it here if you would like to get a bit more in depth about it: www.w3schools.com/xml/xml_whatis.asp
In any case, I’ll show you what you need to do in the object tuning to get it working for you and explain a bit about what each section of XML does.
3.1.1 Making the object ready for interactions
In order for your object to have the right interactions available, and for it to change states accordingly, you will have to do some changes to the XML of the object tuning so that your states and interactions are properly referenced.
For that, the object tuning needs these basic things defined:
- It has information about what states is available.
- It has information about what interactions is available.
Let’s go through my object tuning as it is when I added it.
We can see that it has an element named _components, and one named state.
In the _components element, there are different components defined for the object. We can see that there’s information about something called focus. This simply sets how interesting this object is to the sim interacting with it. By default, for this tuning, it is set to LOW, meaning it is of low interest. You can also set it to HIGH, MEDIUM or NONE if you don’t want it to be of any interest at all. You could also remove the entire thing as you don’t need it.
After that we have the state element which defines information about the states available for this object. This object tuning has by default two sets of client states. The way I understand it, is that it means that the object has two “groups” of states available to it. One group contains states that has to do with some specific theme, and the other group has something to do with another specific theme. In this case, we have “burn” states grouped together, and “admire” states grouped together.
Underneath each client state "group", there is also information about which of the states should be the default state for each group.
Finally, we have the super_affordances element which specifies the interactions which are available to this object. In this case, there are some default interactions that are available in certain circumstances, such as for “cheats“ and “debug” but wont be displayed in normal circumstances.
3.1.2 Removing client states
Since we only really need one client_state group defined, we can remove all the other ones. The simplest way to do that is to find the U tag (<U>) that the client state is wrapped in and minimize it by pressing the minus (-) symbol next to it on the right side. Then you simply select the line and delete it.
Do the same with any of the other client state groups until you only have one left.
3.1.3 Adding object states
Now you can edit the information in the one that is left to have the states of your object. To do this, you want to go to one of your states, copy its tuning id and paste it into one of the T tags (<T>) with the key information. Like in the screenshot below.
Here I have pasted the tuning id for the “Opened” state I have.
Next to the key is a comment which shows in green. This comment doesn’t provide any information that Sims 4 Studio or the game can read, but it only serves as information for you to better understand what this key refers to. You can edit this comment so that it shows the name of the object state. Simply delete everything between the “<!—"and “-->” and paste your object tuning name there. This is highly recommended as you otherwise may get confused as to what this key is later.
An XML comment always needs to have the right structure to work as a comment, so make sure you don’t accidentally remove any of the dashes, “<”, “>” or “!” characters that come before and after the comments text.
Add your second state into the other one, and the third one into the third and so on. If you need to add more states, you will want to copy the whole U element that the T key is wrapped in and paste it underneath the one you just copied. Then edit the T key for that as well to add another state of yours.
To delete one, do the same but delete instead of copying the U wrap.
Then edit the “default” key value to be the tuning id of the one you want to be the default one.
In my tuning, it looks like this now with all my states added and one removed, as I only need two:
In my tuning, it looks like this now with all my states added and one removed, as I only need two:
Next step is to copy the Name and TuningId of the object tuning from the data tab and paste it into the Object Definition’s tuning reference (Tuning and TuningId) in its data tab so it can reference it.
3.1.4 Adding Interactions
Now let’s go to the _super_affordances element in the object tuning and change it to have the interactions we want.
If you go through your interactions list in your tuning file, you may see some interactions you don’t want. Just delete those from the list. Then add your own interactions by referencing their tuning id's like we have done before between two T tags.
Here you can see I’ve added my two interactions to open and close the curtains.
3.1.5 Editing Object States
Now let’s continue with the object states.
I’ll start with editing my Opened state. This is the state that my object will be in after it has been opened.
As you can see, it doesn’t contain too much XML in it to start with. But we’re going to reduce it even more to only one line of XML!
You can see how there’s three different elements defined: new_client_state, broadcaster and material_state. They all add extra information about this state.
new_client_state contains information about what sound should be played in conjunction with this object state being used. It says that it should change the audio state to play a new sound.
So, we could also have audio playing for our object that we also switch between when interacting with our object. However, we’re not going to be looking into that in this tutorial, and it’s not something I have personally looked into yet, but at least you know that it exists in case that’s something you want to dive into later on!
Inside the T tag with the name audio, you can see a path to an audio file that will play the sound of, in this case, the ceiling fan.
Next is the broadcaster element which specifies what effects will apply to the sim in conjunction with this state being used. In the case of the ceiling fan, the sim can either receive the effect of cooling or drying.
Last thing is a material_state element which lets the game know which material should be used with this state. Here it has set the material state to the “on” material which is defined in the ceiling fan models material list.
Now, we’re not going to be using these for this tutorial, so we will simply delete all of them and only keep the very first element available, which is the I (instance). So, the tuning will now look like this:
This is all that is needed for this to be recognized as an object state.
Do the same with your other object state tunings, except for the one that lists all the object states.
In the object state tuning that contains the list of all the object tunings available, you'll want to reference your object states instead of the ones specified by default. Use the tuning id's as the references.
3.1.6 Interaction tuning editing
Select one of your interaction tunings. I’m starting with my Open interaction.
In the interaction tuning, there is quite a bit more XML present.
At the very top you should see one line of XML that says _saveable. It specifies if this interaction should be able to be saved together with the sim when you save your game. If I understand this correctly, it basically means that anything that happens after you chose this interaction can be saved and continued the next time you open the saved game. Since this interaction tuning works with the ceiling fan per default, it says it should be “disabled”. We can also leave this off since our interaction and whatever happens after, happens immediately, so there’s a small likelihood anyone would save their game in that small amount of time of the interaction.
Then we have display_name which specifies what name this interaction should have in game. As you can see, it uses a hashed value of the text “Turn On” instead of having the text as the value. When we want to change this text to be of our own instead, we will have to add a hashed value of the new text into the string tables, so the game knows what this value means.
Let’s change our interactions display name now, so that the game shows our wanted text instead of this “Turn on” text (unless it fits for your object! ).
To change the interaction text, let’s go to the Hash Generator again. In my case, I want to use the text “Open” so I will enter that into the text field.
Next, we copy the FNV32 fields value this time, instead of the FNV64, and close the hash generator.
Next, we copy the FNV32 fields value this time, instead of the FNV64, and close the hash generator.
In the interaction tuning, we now want to enter this value after the 0x part. Then in the comment, we put what this hashed value means in text. For my interaction tuning, it looks like the below screenshot now.
Then we must add this value and its text meaning to the string table of the different languages so the game can find out what this value means.
So, copy the value you just pasted and go to the English string table at the very top of the warehouse tab, and click on edit entries. Then click Add and paste the value into the Value field, and the text in the Name field. Then click Save.
Then you want to make sure all the different languages of the game has this text available, so that others who play the game and plays it in another language and uses your object can see this interaction text as well. To do this, go to the Tools menu, then to Modding and choose copy string tables to all languages. This way you don’t have to manually add it to all languages. Note however, that this specific interaction text will say “Open” in English for all languages. If you know any other languages, you can of course edit them manually to use the right word for it along with this hashed value.
Back to the interaction tuning, we have display_name_overrides. This section tests what interaction name should be used if a specific state is set, and then sets the name depending on the result of the test. It says that the new display name of the interaction should be “Turn Off” if the object is in the state of “ceilingFan_On”. This is because, this interaction tuning is set up to handle all of the interactions and all the outcomes of those interactions instead of using different interaction tunings to set them individually.
To delete it, simply minimize it with the - icon next to it, and then select it and delete it.
The next thing up is display_name_text_tokens.
I’m not entirely sure what this does, but finding some information on other sites has lead me to believe it has to do with the Sims 4 UI (user interface). So I'm guessing it tells the UI how the interaction displays to the user in some way, but not sure. If anyone has more knowledge about this, feel free to leave a response letting us others know. Thanks.
We can leave this alone as it is.
Next part is interaction_category_tags.
This one does not set any information that affects the gameplay in away, but is seemingly used for testing and other purposes for the Sims 4 game developers.
We can leave this alone as well.
Next is a long section of outcome information.
This section provides information to the game about different outcomes from using the interaction which triggered this tuning. In this case, it’s specified what object state should be set when using the interaction as an outcome.
It specifies that if the object state is “on” when this interaction is used, then the object state should now switch to “off”, and vice versa. So, it tests what the object state is in, and then sets the new state accordingly.
It specifies that if the object state is “on” when this interaction is used, then the object state should now switch to “off”, and vice versa. So, it tests what the object state is in, and then sets the new state accordingly.
We can see in it, that it has fallback_outcomes and tested_outcomes.
So basically, the fallback outcome is what the object state should be set to by default, in this case “on”, when using this interaction, but only if the object isn’t already set to “on” which is determined by the tested_outcomes with its testing. If it is already “on”, it should instead set to “off”.
If we scroll down slightly, we’ll see a section called tests within the tested_outcomes section. That is the actual testing portion which asks, “is this objects state set to ceilingFan_on?”. If it is, then the outcome section just above that will set the objects state to “Off” instead.
We only need a small portion of outcome test for this tutorial, because we’re using several interaction tunings instead of just one and will therefore be setting the object state in each of them.
So, to make this easier to modify, we’ll simply delete the whole outcome section first, and then add in a shortened version of the XML section.
Simply minimize this section by clicking the - icon next to it, and then delete it.
So, to make this easier to modify, we’ll simply delete the whole outcome section first, and then add in a shortened version of the XML section.
Simply minimize this section by clicking the - icon next to it, and then delete it.
Next, you want to add in this snippet of XML instead for the outcome of this tuning:
<V n="outcome" t="single">
<U n="single">
<U n="actions">
<L n="basic_extras">
<V t="state_change">
<U n="state_change">
<V n="new_value" t="single_value">
<U n="single_value">
<T n="new_value">object state instance<!--Object state name--></T>
</U>
</V>
</U>
</V>
</L>
</U>
</U>
</V>
As you can see, this outcome section specifies that the outcome is a single outcome and sets a new object state. That is all you need for the object to switch the object state on interaction.
Then you want to change the object state instance to the instance key of the object state that will be the outcome of this interaction. In my case, since I’m working with the Open interaction, I want to set my object to be in the state of Opened as the outcome.
Next up is pie_menu_icon.
This specifies that there should be an icon next to the interaction, and it specifies a file path to the image of the icon. The icon is the classic orange “target” symbol you see next to some interactions in game. You don’t of course need this as the interaction will work just fine without it.
If you want to, you can delete it. Otherwise, leave it be.
Next is a progress_bar_enabled section.
This specifies if the object should have a progress bar. The progress bar can show the progress of the interaction.
We’re not going to dive into that, and it’s not needed for the object, so we can remove it completely.
Next, we have the line target_type.
This defines what the target type is for this interaction, and is already set to “OBJECT” instead of "Actor". If we had "Actor" as the value instead, the interaction wouldn't work on the object.
Since we want the interaction to be applied to the object, we will leave this as it is. You do not want to remove this as it’s necessary to be specified for the interaction to show up at all.
The second to last section is the test_globals.
A global test section tests if certain situations are true in game, and if all those tests pass, the interaction will work. If one of the tests does not pass, the interaction will not work, even if the other tests does pass.
We can see that there’s a V element with the name sim_info.
This contains tests that applies to the sim only.
In this case, we can see a list of sim ages that can interact with the object. So, if your sim is any of these ages when they choose the interaction on the object, then this test returns “true”.
Since we have all the ages specified, the ages test will always return true (it passes) when you’re playing the game.
We also have a species test. In this case, it is empty and means that this test will always return true for all species. You could do the same with the sim ages test, just leave it empty, and it would then always return true because no ages specified means all ages will be allowed.
Then we have the who part, which checks these tests against the Actor (sim).
You may have already guessed it, but we need to add another test to this section as well to see what state the object is in when we choose this interaction. Since this interaction shows “Open” (in my case), then we naturally want this interaction to be available when the object is in the state of “Closed”. So, I will add a test that asks if the object state is closed.
You can copy paste this XML snippet and paste it into the global tests section:
<V t="state">
<U n="state">
<E n="operator">EQUAL</E>
<T n="value">Object state instance<!--Object state name--></T>
</U>
</V>
You want to paste it after the sim_info V-tag section.
This test checks if the state is “EQUAL” to the object state we have defined. In my case, I will set it to test if my object is “closed”. Because then, we should be able to open it.
This test checks if the state is “EQUAL” to the object state we have defined. In my case, I will set it to test if my object is “closed”. Because then, we should be able to open it.
Now you can edit these different tests to fit your needs. For example, if you only want certain ages to be able to interact with the object, then simply delete the ones you don’t want.
If you want to allow all ages, you can leave it as it is, or, you can delete the whole specified section by selecting it and deleting it.
If you want to allow all ages, you can leave it as it is, or, you can delete the whole specified section by selecting it and deleting it.
Below that you can see the species section. It’s already empty, so this interaction isn’t limited to any specific species. If you want to limit it, you can enter the species that can interact with this object. Otherwise you can leave it empty.
Finally, the last XML section we have is called utility_info.
This part informs the game of what utilities this object needs in order to be interact-able. In this case, it’s specified that it should have the “POWER” utility, as it runs on power.
In our case, we can remove this completely as we’re not going to use it.
Now you can go on to the other interaction tunings and do the same thing. However, you don’t need to edit every single bit all over again but can simply copy paste this interaction tunings content and paste it over the next one. Then you only need to change a few things in it to be correct.
So, I will go to my “close” interaction next and paste the “open” interactions XML into it instead.
Then I want to immediately change the name of this interaction tuning in the data tab and then go on to make the correct changes for each part of the tuning as we did before.
Then I want to immediately change the name of this interaction tuning in the data tab and then go on to make the correct changes for each part of the tuning as we did before.
Step 4 – Adding animation tunings and ASM
Now that we have the interactions down for the object, we can start adding some animation tunings and an ASM so the object can animate!
An ASM (Animation State Machine) sets different animation states that the object can have. An animation state is like an object state, except for animations instead of the object. For each animation state, there’s an animation file that will play that is also defined in the ASM.
You also define how the animation states connect with each other. If we take my curtains object as an example, I will want to have an animation state of “opening” which is the animation of the opening of the curtains. I will also want an animation state of “closing” the curtains. But I also want an animation state of the object being “opened” and “closed” so that once the object is done animating the opening, it will stay opened and once it’s done animating the closing, it will stay closed.
In the opened and closed animation states, I will therefore supply with animations that just has the object “still” in the opened pose, and one just “still” in the closed pose. Then I make connections between these so the ASM knows how to animate.
More on this later.
The animation tunings direct the ASM when to animate and with what animation states by telling it how to start and end. The animation tunings are in turn, called by different interactions on the object.
4.1 Adding an ASM
So first, let’s add an ASM.
To do this, you won’t go through the “Extract Tuning” feature like before because the ASM is not a tuning. This time, you must extract one via the Game Cruiser option available in the Tools menu as well. Once you have opened it up, you’ll want to choose Animation State Machine as the filter option, and then you can simply pick whichever ASM listed. However, I feel the first one that comes up is quite easy to work with and is named “spookyCandyBowl_eatCandy”, so I recommend choosing it.
Now you may think “But I don’t have the spooky pack this ASM comes with! It won’t work for me or anyone who don’t have this pack!”. I understand your concern, but the good news is you can actually still use it as it’s not dependent on owning the pack to work. We’re also going to change the contents of its XML so it’s not referring to any spooky stuff pack content anyways. So again, you can pick any ASM you can find in the list and then just tweak it to work for your object.
After we have added this one to our package, we’ll want to first of all change the name of this ASM. Now you’ll probably notice that it doesn’t have a tuning id you can change in the data tab. What you will have to do instead, is to change the name at the top of the ASM, as well as making a new hashed instance key value and paste it into the Instance field in the data tab.
You can copy the name of the ASM that you chose and use that to hash the new instance value.
Let’s switch back to the XML tab and go through the different parts of this ASM.
First, we have Actor.
This tells the game what kind of actor we want to animate. In this case, it says by default that it should be of the type “Sim” and the name property is set to “x” (which refers to the sim). This is what you would want to have specified when you want to animate a sim.
Since we’re going to be animating an object, we’re going to change this to be of the type “Object” instead.
Then we also want to change the name property of this actor. Since we want the object to animate and not a sim, we want to change the “x” to a name we want to associate with our object.
This name is only used within the ASM and animation tunings.
I’ll name mine “Curtains”, simple but descriptive.
Then we also want to remove its property master which is set to true. Since we’re talking about an object and not a sim, this is not needed.
Now it should look something like the screenshot below so far.
The next two lines of XML tells the game, as you may be able to tell, what sim ages this animation will apply to and what gender. However, again, this applies to animating a sim, so we’re going to completely remove these two lines.
Next, we have a IKConfiguration.
This contains information about what animation file we want to hook up to what actor. We don’t really need this for our object however, because we can define this in the XML further down instead. However, when it comes to animating sims, I’m unsure how needed this section is.
Let’s delete this it since we don’t need it.
Then we have two PostureManifest sections.
These are, again, paired with sim animations and has to do with posture. We don’t need this either so let’s remove those.
Next, we have State.
This is where we define an animation state for our object, and we can add more of these as needed. In this ASM we can tell that it’s of the type “public” and has the name “Eat Candy”. This means, that this is the “Eat Candy” animation state for the spooky candy bowl object.
It can have the type of “public” or “private”. This seemingly has to do with starting points and ending points of an animation sequence. A public type is that which is the start or end of an animation sequence, and the private type is that which is in between the start and end of an animation sequence. More on this further down.
We’re going to first change this to have a name of one of our animation states. Since I want an opening animation, I will name this state to “Opening” instead of “Eat Candy”.
Then I want an “Opened” animation state, that is going to be for when the object has finished opening and should now be “Opened”.
Then I’ll continue adding the rest of my animation states of “Closing” and “Closed” and set them to the right types as discussed above.
Then I want an “Opened” animation state, that is going to be for when the object has finished opening and should now be “Opened”.
Then I’ll continue adding the rest of my animation states of “Closing” and “Closed” and set them to the right types as discussed above.
Below is a screenshot of what it now looks like.
Next, we have a Connection.
Connections is used to make different animation sequences. An animation sequence is when an animation plays out, and once it is finished, it is followed by one or more other animations. Therefore, we have an animation sequence of different animations playing one after the other. How this sequence plays out is determined by the animation tunings which we will look at later.
Here we can see that by default for this ASM, there’s one connection that goes from “Eat Candy” to “Exit” and another connection that goes from “entry” to “Eat Candy”. In this case, the animation sequence only consists of one animation (Eat Candy). Once the animation is done, it simply “exits” instead of leading to another animation once it’s complete.
A connection that goes from “entry” to an animation state, means that the animation state is a starting point in an animation sequence. A connection that goes from an animation state to “exit”, means that the animation state is an ending point of an animation sequence.
“exit” isn’t an animation state you have to define yourself like we did before, but think of it more as a “command” that tells the ASM that once the animation state is done animating, we want to “exit” (quit) from it. The same goes with “entry”. You don’t have to define it as an animation state type, the ASM simply knows this means “starting point”.
Let’s take my object as an example. I want to make two animation sequences.
- One that is opening the curtains.
- One that is closing the curtains.
So, here’s the connections I want to make for these two sequences.
- From “entry” to “Opened”. Because the opened state is the start of the opening animation sequence.
- From “entry” to “Closed”. Because the closed state is the start of the closing animation sequence.
- From “Opened” to “Closing”. Because when the curtains are opened, you can close them as a part of the closing animation sequence.
- From “Closing” to “Closed”. Because when the curtains are done closing, they should be closed as a part of the closing animation sequence.
- From “Closed” to “exit”. Because this is the end of the closing animation sequence.
- From “Closed” to “Opening”. Because when the curtains are closed, you can open them as a part of the opening animation sequence.
- From “Opening” to “Opened”. Because when the curtains are done opening, they should be opened as a part of the opening animation sequence.
- From “Opened” to “exit”. Because this is at the end of the opening animation sequence.
As you can see, I have chosen the “closed” and “opened” animation states to be the “exit” points, as this is where I don’t want to continue with anymore animations, the animation sequences are therefore complete.
After you have worked this out for your object, you want to go to back up to your animation states and set the type values for each to either be “public” or “private”. If the state is a starting point or ending point of a sequence, then it should be set to public. If it’s not either of those, then it should be set to private.
That’s it for the connections. I’ll go ahead and add mine to my object as described above. You’ll want to figure out what connections you want to make for your object in the same way.
Now my ASM looks like this:
Now my ASM looks like this:
Next thing up is another State.
This one wraps the information about what animation file should play for this specific state, as well as information about how long the transition should be to and from this animation. It also has some extra XML we don’t need that, again, has to do with sim animations.
Firstly, we will only have this state section specify its name property, and not any of the other properties since those are already defined at the top of the ASM.
So, let’s remove everything after the name property but keep the last tag (>). Like in the screenshot below.
So, let’s remove everything after the name property but keep the last tag (>). Like in the screenshot below.
Then let’s change the name from “Eat Candy” to one of our objects animation state names that we specified earlier. In my case, I’ll start with the “Opened” state.
Next, we can remove some parts of this state section. We don’t need the PostureSelector or the Choise element because we’re not working with sim animations. But we do need the Controller, TransitionClassList and the description, so we’re going to remove everything except for these three so it will look like the below screenshot.
Now another important step to do here, is to add an element wrapper called MakeController. This is crucial for the object to stay in the animation state that we want it to be in after it has animated. So, you will want to add the wrapper tags before and after the Controller element. So it will look like the screenshot below.
Now we can just copy and paste the State section so we can set more animations for all our animation states. Then we set the correct animation state name for each of them.
Mine looks like the below screenshot after this has been done.
Mine looks like the below screenshot after this has been done.
If we quickly have a look at one of the “Controller” elements inside one of these states, we can see that it has a property called controller and that it has a value that starts with “@clipcontroller(clip=…”. It is inside this that we will later add the name of our animation clip that we will have imported to the package. We will also want to specify that the target should be the object's name, and not “x” (for the sim).
But let’s leave this ASM for now and continue with adding some animation tunings! Don’t forget to save your package now and then so you don’t accidentally lose any changes.
4.2 Adding Animation Tunings
Animation tunings hold information about what animation state should play its animation, and what should happen once that animation is finished. The animation tuning is called to do the animation by the object’s interactions in some way.
In my case, I will want to add 4 animation tunings: “opened”, “closed”, “opening” and “closing”, just as we have defined in the ASM for our animation states. But I only need to add one animation tuning to then duplicate to be as many as I need and rename each of them (same as we did before for the other tunings).
In extract tuning, I chose to go with “animation/Kick_Trash_Pile” to add to my package. You can choose this one too, so it's easier to follow along the tutorial.
I will rename this tuning straight away, just like we have done before in the data tab. I’ll make this first animation tuning my “Opening” animation tuning, so I’ll rename it accordingly.
Then we’ll switch to the XML tab and make some changes.
First, we can see at the top that this is an instance of the type animation (i=”animation”), and that it is of the class AnimationElement (c=”AnimationElement”).
For our object to be able to use this animation tuning, it needs to be of the class ObjectAnimationElement instead. So, we will edit it to say that instead.
Then we have the m property which stands for “module”. We want to change its value to be that of an object animation as well, so we will type in animation.object_animation instead.
Next, we can see that there’s something called asm_key, and in it there’s a property called p which is short for “path”. It contains the path to the ASM that should be used for this object’s animations.
We can also see a long combination of numbers and letters, separated by colons. We only need to be aware of the last part that comes after the last colon, as it refers to the instance key of the ASM.
If we go back to the path property for a bit, you may wonder what you’re supposed to be putting here instead of the “Trash_Pile.interactionasm”. In this case, it actually doesn’t matter what file it is told to use. The only thing it really needs in order to find the right ASM is to reference the instance key for it. So, you can leave the path as it is, delete it completely so that it only has an empty set of quotes “”, delete the entire property (p) or enter a fake path that doesn’t exist.
In my case, I’m just going to make up a “fake” path so that it looks like the screenshot below.
Now I will change the ASM instance key reference to the one I have by simply deleting the instance key that is after the last colon, and then copying the instance key in the data tab of my ASM and pasting it where the other one was just before. Like in the screenshot below.
Now the game will know what ASM to use with this animation tuning.
Next we can see that there’s begin_states and end_states.
Animation tunings makes animation state requests to an ASM via these two elements. In other words, it instructs the ASM how to animate.
I will attempt at describing what these do in the way I understand it and in relation to my object.
If I defined the begin_states to be “Opening” (opening animation), and the end_states to be “exit”, then it would play out something like below.
The animation tuning basically says “Hey ASM! I was called by an interaction with the object. My job is to tell you that you should find animation state ‘Opening’ as defined in my ‘begin_states’ and play it. I have no starting connection defined”.
If you can remember, we set the ASM to have several connections. In the case of the “opening” animation state, it only has one connection (from “opening” to “opened”). So in this case, the ASM knows that this is the connection it should play out without having to be told.
Then the ASM says “Hey animation tuning! Ok, I will look for animation state connection ‘from Opening to Opened’ and play that out”. That will in turn, in game, play the “Opening” animation and then the “Opened” animation.
Once the ASM has finished playing the “Opened” animation which is what the “Opening” animation connects to, the animation tuning goes “Ok, now exit from that animation” as defined in my “end_states”. To which the ASM replies with “Ok, I have exited from it! What’s next?”.
However, if I were to set the “Opened” animation state as the beginning instead, then the ASM wouldn’t know which connection to start playing, because we have defined two of them (from “entry” to “Opened” and from “Opened” to “Opening”). However, the animation tuning will then tell it, that if it doesn’t know where to start, then default to the “entry” point connection (entry to opened).
So, then the ASM would play, from “entry” to “opened”. Then it will go to the end_states to see what to do next. If we have specified “exit”, then the ASM will find the exit state connection for the “opened” animation state and play that out.
We could, however, instead have specified that the end_states should have been “Closing” or any of the other animation states we have. Then the ASM would have first played the connection of “Opening” to “Opened” and then immediately after played the “Closing” to “Closed” animation as the “end”. Then because there’s no “exit” instruction, it just keeps looping between these two connections, so in game, it would just keep looping between opening and closing until another interaction on the object intervenes.
That’s why you should generally only use “exit” in the “end_states” or leave it empty so the ASM can exit or auto-exit after the connection is done playing.
There are however some looping settings one can set in either the ASM on animation tuning. How this works with the beginning and ending methods I'm not entirely sure, but should be relatively simple to find out by reading TDESC files.
Since I’m working with the “Opening” animation tuning, I am going to specify that I want the beginning state to be “Opening”. For the end_states, I will specify “exit”. This causes, as I said before, the ASM to find the connection from “entry” to “Opening”, play that out and then exit.
So now my animation tuning looks like the screenshot below.
The final thing we need to do is to specify that this animation tuning is for our object in question. So, we’ll have to add a line of XML that specifies this underneath the end_states.
This is what you will want to copy and paste in:
The Object name should be that which you defined in the ASM. In my case, this is “Curtains”.
<T n="actor_name">Object name</T>
The Object name should be that which you defined in the ASM. In my case, this is “Curtains”.
That’s it for the markup of the animation tuning.
Now I’ll continue making the rest of my animation tunings by duplication, as we have done before and make changes to them.
Now I’ll continue making the rest of my animation tunings by duplication, as we have done before and make changes to them.
In the “Opened” animation tuning, I have beginning state “Opened” and exit state “exit”. In the “Closing” one, its “Closing” and “exit”, and in the “Closed” it’s “Closed” and exit.
Now we have all the tunings done and ASM. Let’s now continue with getting our object to look the way we want it to and animating it!
Now we have all the tunings done and ASM. Let’s now continue with getting our object to look the way we want it to and animating it!
Step 5 – Editing the object mesh, rigging and animating it
Now is the time to make edits to the mesh if you haven’t already done so.
In my case, I’ll add the curtains mesh in place of the painting, making sure the cut number is correct. When you are done with your object, we will go ahead and do some rigging!
5.1 Adding bones in Sims 4 Studio
Let’s start adding more bones to our object. If you’re not planning on animating separate parts of your object mesh, then you do not need to do this part.
You want to go to the Studio tab, and then go to the Rig/Slots section. Here you want to add the bones you think your object needs. Usually, one bone per part that should animate. You could go more advanced and make your object have a more complex rig, but I won’t go into how to make that happen here, and it’s also very individual to every person.
Click on the transformBone bone that is listed there, and then press the Add button.
A new bone is now listed together with the other default bones and it’s parented to the transformBone. Now you will want to name this to something fitting. In my case, I’ll have two bones. One for the left part of the curtain and the right as seen in the screenshot below.
A new bone is now listed together with the other default bones and it’s parented to the transformBone. Now you will want to name this to something fitting. In my case, I’ll have two bones. One for the left part of the curtain and the right as seen in the screenshot below.
We will tell Sims 4 Studio where these bones should be positioned later on after we have re-imported our edited mesh.
Then you want to go into the Warehouse tab and select the Rig for this object. In the Bones section, it will have all your newly added bones listed. You want to copy each of these bone’s hashed name values and paste them into each of your object’s lod’s. If your object has shadow lod’s, you will want to add the bones to them also. If you don’t then the shadows will stay put while your object animates, which isn’t too pretty.
So, select one of your Model lod’s and in the Data tab, click edit entries for the Meshes section and choose the model mesh that contains your object. It typically will have two listed, one called DropShadow which is the shadow part of the object (the plane with the shadow texture on it, not the shadow lod), and then either Instanced or Phong which will be for the object. You do not want to add any bones to the shadow plane, only the object.
Then choose edit entries for the Bones section. In the window that pops up, you want to add your bones hashed name values that you copied earlier from the Rig. Mine looks like the below screenshot now with my two bones added.
Then press save, and in the other window that is still up, scroll down until your find the BindPoseBones section.
In there, you want to add your bones as well and in the InversePoseBones fields, you want to add “Identity” instead of the 0’s that are present.
We will later adjust this with a Sims 4 Studio feature that will convert this to matrix values of the orientation and position of the bone according to the rig in the blender file we will later import.
Do these steps for each of your regular model lod’s and the shadow lod's.
Then once you’re done, select the Model in the Warehouse and do the same steps as before. Look for the lod in there that has a button to edit meshes and add your bones the same way. Don’t forget the BindPoseBones section here as well.
5.2 Editing the object mesh rig in blender
Now we can export our object to edit the mesh and its rig in Blender. I chose to start with my High model lod, and then just use it for all the different mesh resolutions. But you can of course use different resolutions of your mesh if you want, which will be helpful to those who will use your CC and don't have a speedy computer that can handle high resolutions very well.
Since we added all the bones to Sims 4 Studio already, they will automatically be added in the blender file that we exported.
In my case, I want the curtains mesh instead of the paintings mesh, so I’ll swap the mesh for that. Once you’re done with your object, let’s continue editing the bones positions!
In blender, expand your mesh armature in the rig and chose one of your added bones. You’ll want to position this bone to where it should be located on your mesh. Make it somewhat centered to the part of the mesh you want to be able to animate.
I usually just move the bone around with the different axis arrows. I set the right curtain bone to the right curtain fabric, and the left one to the left side so it looks like the screenshots below.
The bones now touch the parts of the mesh I want to be able to move. They don’t really have to touch the mesh to work, but I prefer doing it like this because it shows me better what bone is attached to what.
You can see there’s a dashed line following the bones from the transformBone. This just a feature in blender to illustrate that the bones are children of another bone, in this case, the transformBone.
5.4 Weight painting the mesh parts
Now we need to tell blender how these bones attach to the mesh. To do that, we need to use weight painting of red and blue.
We will first go into edit mode of our mesh, and then select the parts of the mesh we wan to be able to animate. In my case, I only want to animate the curtain fabric, and not the curtain rod.
So, I will first select all the faces of the right curtain fabric so I can bind it to the bone. Selecting it looks like the screenshot below.
Note that I have made sure that every single face of this part of the curtain in selected which is important.
Then, I want to add this selection to a new vertex group. To do this, I will go to the object data tab and locate the vertex groups section and add a new one by pressing the plus button next to it. Then I’ll name it the same as the bone. After that, I want to make sure the Weight field below the vertex groups is set to 1 (red weight paint) and press the assign button.
This will cause the selected areas of the mesh to be added to the vertex group we created, with red weight paint. I’ll do the same for the other side of the curtain.
This will cause the selected areas of the mesh to be added to the vertex group we created, with red weight paint. I’ll do the same for the other side of the curtain.
Now both sides of the curtain have their own vertex groups.
You can test that you did this right by selecting one of the vertex groups you created and press the select button. This should highlight the correct part of the mesh. Then press deselect and select the other vertex group and press select again. Now the other part of the mesh should be highlighted.
If you select the transformBone vertex group and press select, you’ll see the entire mesh is highlighted. We will need to change this so that our object animates correctly. We’ll go into that next.
Now let’s go into weight paint mode for our object.
If you select one of your vertex groups in the list, you’ll see how the red weight paint shows up on the parts of the mesh that is in this vertex group. It is only because we used the assign button with the weight field set to 1 that makes this part red. If we would have set it to 0, it would have been blue.
This is how it should be, as red weight paint means that the bone for this vertex group is only going to be moving the red parts of the mesh and nothing else. Anything is blue will stay stationary.
Now, we do need to change the weight paint for the transformBone vertex group as well. Because by default, the whole mesh is weight painted red and this will cause problems when we want to play our animations in game.
In this case, we want to set the parts of the mesh that doesn't already have their own vertex groups to a red color, and the ones that do have their own vertex groups to have blue weight paint. In my case, the curtain rod will not animate, so it should have red weight paint and the rest of the model should have blue weight paint as shown in the screenshot below.
To do this, first make sure you are in the weight paint mode, and then select the whole mesh. You can do that by pressing A on your keyboard while having the little box icon with a checkered pattern selected in the menu bar below.
Then go up to the upper left side where you have weight paint settings. Make sure that the weight field is set to 0.
Then, go down to the menu item which says Weights and select Set Weight at the top of the menu that expands.
This will cause the entire mesh for this transformBone vertex group to turn blue.
Next, select only the parts which you want to have red. Again, it should be the parts that don't have their own vertex groups (like the right and left curtain). In my case, that leaves only the curtain rod at the top.
Now, you want to set this to a red color by going up to the weight paint settings again, and setting the Weight field to 1. Then go to the Weight menu again and choose Set Weight.
Now the transformBone vertex group has the right weight paint.
That’s it for the bone rigging and weight painting!
To test if all works correctly, you can switch into object mode, and then expand Pose in the rig and select one of your bones. You will automatically switch into Pose Mode by doing this. Then try moving the bone around and see if the correct part of your mesh moves with it. If it does, then you have done it correctly.
In the screenshot below, I have selected my right curtain bone and moved it to the center to test if it works. And as you can see, it does work.
Next, let’s import the mesh back into studio.
As I said earlier, I’ll use the same mesh for all the resolutions, so I’ll import this mesh into all of them (high and medium in my case), but you can go ahead and make yours different if you like.
I also make sure that I make a shadow lod version of this object with this same rig structure, and import it into Sims 4 Studio for each of the shadow lod's.
I also make sure that I make a shadow lod version of this object with this same rig structure, and import it into Sims 4 Studio for each of the shadow lod's.
Then we also want to make sure that we set each bone's position in Sims 4 Studio as this wont transfer from blender into studio automatically. So go to the Rig/slots and copy the Transform values: x, y and z from your bone's position in the Bone data tab, like shown in the screenshot below. You need to select your bones under the None_Armature_Data and NOT the Pose for this to work. You only need to copy the Head values.
In Sims 4 studio, it will look like this for me now:
Then go to the Tools menu and choose Modding, followed by sync rig changes to slot. This will now automatically update all your bones positions and orientations in the warehouse tab, where you had previously set the value "Identity" for the bones.
5.5 Animating the object
Let’s go ahead and animate our object now that we have rigged and weight mapped it. So let’s open up the object mesh again in blender and save a copy of it that we’ll name differently so we’ll know it contains the animation we want.
I’ll start with creating my “Closing” animation, so I’ll name this blender file to reflect this “curtains-ClosingAnim.blend”.
Once you have yours ready, we can start animating.
To do so, you should have the timeline editor open, as well as the dope sheet editor open. I usually have my timeline editor at the bottom of the screen and the dope sheet editor to the right side, like in the screenshot below.
Then, I’ll want to edit the timeline to be that of the length of the animation. I want mine to animate for 2 seconds, so I’ll make the timeline into 120 frames wide. 60 frames = 1 second in game. I’ll also set the timeline to start at 0 instead of 1.
Now comes the animation part.
The first frame should be that of the curtains being opened, and the last frame should be that of the curtains being closed. So I'll select my two bones under Pose (not armature this time), then create a new keyframe on the very first frame without moving my bones anywhere by pressing I on the keyboard and choosing LocRot. This way, I have the curtains in a original position to start with.
After you have created a new keyframe with these bones, you should be able to see in the dope sheet editor, that there are orange dots representing the keyframes set for all of those bones at the start of the timeline, next to their names.
Then I’ll go to the last frame (120) and move each of the bones so that the curtains look closed. Then I want to add a keyframe here as well with both the bones selected.
Now there’s two yellow lines in the timeline marking where there’s keyframes added. One for the opened position at the very start, and one where it's closed at the very end.
Now there’s two yellow lines in the timeline marking where there’s keyframes added. One for the opened position at the very start, and one where it's closed at the very end.
If I now play the animation or move the green line around in the timeline, I’ll see that the object is animating.
By viewing the dope sheet editor, I can also see dots indicating the keyframes I just added for the _curtain_right and _curtain_left bones.
Great. That’s all I needed to animate for my curtains to animate it's closing animation, so I’ll go ahead and save this and then continue making my other animations.
I will use this animation as a base for the others, so I can make sure all the animations transition seamlessly. For example, to make the “Closed” animation that will come after this “Closing” animation, I will simply delete the keyframes that have the object in the opened pose in the first frame, and copy the closed pose rom the last keyframe into the first frame instead. This way, I have two identical keyframes of the object in the closed pose. It will show up in the dope sheet editor as a straight orange line connecting the keyframes, because the keyframes are identical.
This way, I have an animation that doesn’t really animate anything, but simply keeps the object in the “Closed” pose. Also, the bones are positioned in the same way as the “Closing” animation’s last frame, which means the animation will look seamless when it transitions into this one.
5.6 Adding the animation files into the package
Once you have created all the animations and saved them, you want to add the animations to a clip pack. Do this by opening another Sim 4 Studio window and create a new clip pack (not override). Then add you name to this clip pack and your creator name.
Then you want to go to the clips tab and add new clips. These clips will contain your animations. Create one clip for each animation, then name the clip what the animation is of. For example, I’ll name my clips to “opening”, “closing”, “closed” and “opened”. Then we want to import our animations into each of these clips by clicking on “import” while having the right clip selected.
Then switch to the warehouse tab and select one of your clips. In it, at the top, change its ActorName from “x” to the objects name that you defined in the ASM. I named mine “Curtains”, so I’ll put that name into there.
Then scroll down until you see ExplicitNameSpaces. Click into the collection field there and add the name there as well.
Then click on the edit entries button for the Events and delete all events there. They are for sim animations, so we don’t need them. Save, then scroll further down to SlotAssignments. Edit the entries there as well to remove all the slot assignments. They are also for sim animations and we don’t need those.
Do these steps for all your clips and clip headers. To speed this process up, you can skip doing the headers and only do the clips. Then save the clip pack, close the sims 4 studio down and then re-open it. Now the clip headers should have the same information as the clips automatically.
Now, select all the clips and clip headers, then scroll up to the very top of the warehouse and select the snippet tuning as well. Then batch export these.
You now want to import these into your objects package, so that the game can reference these clips to animate the object.
You now want to import these into your objects package, so that the game can reference these clips to animate the object.
So, go back into your object package in the warehouse tab and choose Batch Import. Select the binary files that were created when you exported the clips and add them.
Now you have all your clips and clip headers added into your package!
Now, since we have parented our bones to the transformBone, it is likely you will see some odd rotations and misplacement of your mesh parts in game.
This is because the bones you have parented to the transformBone will adjust their rotation based on their placement in relation to the transformBone. So you have to reset their orientation in the clips so it says 0 instead of the value that is already there.
To do this, go into one of your clips (not clip header), click on edit entries for the Channels section. Then click on one of the bones that you made, that has the ChannelSubTarget set to Orentiation. Then set the fields offset and scale to 0. Do NOT do this for the Translation types, as they define how the bone moves, not rotates.
Do this for all of your added bones in this clip (NOT the default ones like transformBone and _focus_), and in the other clips as well. This will make sure that the different parts of your mesh that you have animated won’t get misplaced.
6. The final touches
Now for the last part of this tutorial!
We now want to reference these animations into the ASM. So let’s select our ASM.
Go to your first animation state. Mine is the “Opened” animation state. In there, we have a controller with the property target. Here you want to specify your object as the target, so write your object name as specified earlier in your ASM. For me, this is “Curtains”.
Then, remove the clip that is referenced inside the @clipcontroller(clip=…), which is “a2o_spookyCandyBowl_eatCandy_x” and replace it with your animation for that state.
To find the right animation clip, select a clip and see its SoruceAssetName field. It contains the name of the blender animation file. You want to copy the Name field value and paste it in place of the part we just deleted.
For me it looks like the below screenshot now.
To find the right animation clip, select a clip and see its SoruceAssetName field. It contains the name of the blender animation file. You want to copy the Name field value and paste it in place of the part we just deleted.
For me it looks like the below screenshot now.
Then scroll to the side until you find a property called IkConfiguration.
You want to replace its value with the SoruceAssetName value in the clip. Mine looks like the below screenshot now.
Do the same for the rest of your animation states.
The final step is to go back to your object tuning and add a snippet of XML that will tell the game what animation files go with what object state.
Copy this piece of XML:
Copy this piece of XML:
<V n="idle_component" t="enabled">
<U n="enabled">
<L n="idle_animation_map">
<U>
<T n="key">Object state instance<!--Name of object state--></T>
<T n="value">Animation tuning id<!--animation tuning name--></T>
</U>
</L>
</U>
</V>
Now, paste this into the object tuning file after the focus section inside the _components section. Like in the screenshot below.
The idle_animation_map element sets what idle animation should play for a specific object state when the object isn’t animating any of the ASM’s animation sequences.
So, for example, if we go from animation “Opening” to “Opened”, and the object state is set to “Opened”, then the object animates the “Opening” animation, followed by the “Opened” animation. When the “Opened” animation is done, it will play the idle animation which in this case is also the “Opened” animation.
This idle animation, of course, keeps on playing until you choose to interact with the object again.
This also means you do not need to use geostates at all which makes creating object animations like this much easier.
Then you want to change the values in these to match that of your object. In my case, I have added that the “Opened” object state should have the idle animation of my “Opened” animation. And the “Closed” object state should have the idle animation of the “Closed” animation.
Here you can see how I have added another U element wrap so there’s two of them, each containing one state and one animation tuning belonging together. One for the opening state and its animation, as well as the closing state and it’s animation.
Simply copy paste the U element wrap and paste it below to create more references if you need it.
That’s it! Now you’re all done, and the object should be able to be interacted with and animated in game!
If you are experiencing any problems while following this tutorial, or notice that your object isn't doing what it's supposed to be doing in game, leave a response below. I can't guarantee I will be available to help you very often as I am busy with other work I have. But I'll try to regularly check in and see if I can help. Also, anyone who has anything to add, clarify or even correct are welcome to do so as well!
This tutorial is quite long and I'm impressed you lasted to the end! It took me quite a long time to write and I had to do a few test with different objects in order to understand everything I have written in this tutorial.
So thanks for reading, and good luck with your animated object project!