So as the title suggests, I found a way for the player to put on clothes, via Python with the own.replaceMesh().
The problem is this: If you have a jacket on top that’s partially unzipped, and you have a shirt underneath, the shirt disappears. I was wondering how I could use a mask modifier, but that’s the exact problem with that. Modifiers don’t work in BGE.
So how do I make the mask modifier work in BGE?
I also apologize for like asking 5 questing under one week, but it’s been an inconsistent busy week.
There’s a couple ways to do this. I would likely have two different objects, one for the shirt, another for the jacket. Then you could have any combination of the two articles of clothing without any problems.
well, i would either use 2 objects, 1 shirt 1 jacket, and use change mesh on both.
Or use 1 mesh with a shirt and a jacket, so you just have one mesh to change, the mesh have lets say a few combo’s, grey shirt + black jacket, yellow shirt + black jacket, black shirt + yellow jacket, etc.
There’s a couple ways to do this. I would likely have two different objects, one for the shirt, another for the jacket. Then you could have any combination of the two articles of clothing without any problems.
I think that would work, but both layers are going to clip through each other.
I deform all my character armors(clothes) with the same rig. using the same pivot point and just parent them to the rig upon creation…I hope this makes sense.
it is sometimes unavoidable…for my plate armor on my character…using bow weapons causes the shoulders to clip…but I am going to leave it because bendy flexible plate armor is way less immersive to me.
can be fixed with a shapekey…vertex animation.
I generally do not have any mesh overlap though…I would model a jacket and only the parts of the shirt that are visible…like the front…and there is nothing wrong with asking questions.
Alright, I guess I’m up for it. Except the “shirt” layer is the player’s torso, and the “top/jacket” layers are just an empty mesh. So how do I make the shirt change if the jacket changes?
you can replcace the player mesh, and it is the most convenient, be aware that if you want or have a lot of clothing combinations you will need to create a lot of different models for different clothing combinations…if you only have a few that is fine, but if you have several it could get out of control.
if you use 2 object, chengemesh on both at the same time.
if you use 1 object, you just change the mesh to the one you needed. with 1 object you put the shirt and jacked into the same mesh, just duplicate it, change it colors etc to get an other look.
in python you dont need messages. you use global variables that any script can read. the easiest way to do that is:
import bge
bge.logic.myVar = "something"
while it seems that method is frowned on, it works. the better would be class variables and module variables (global variables). sending values straight to properties is good too.
I assume the “myVar” is the name of the variable, and “something” is the object’s name?
I was considering another method, which involves a more complex alternative to determining which specific piece of cloth to put on. It basically involves the player picking up the item, the mesh is replaced with that item’s mesh. How could I accomplish this?
It’s better not to use the logic engine for it, but globalDict, it’s made for this dta transfer/save and loading.
GD = logic.globalDict
#store data
GD['variable'] = 'data you want to transfer to any object/scene in the .blend file'
#read your data
loaded_data = GD['variable']
When you use the GD you can even use the logic bricks for it to permanently save it on your HDD, and load it when you like.
Alright, then. I was asking a different question though, but it’s fine.
So I’m currently experimenting with a mouse over sensor and a “hitObjectList” property in python. I’m trying to make the mesh be replaced by simply making the mesh replace itself, but with the mesh that the mouse is over(the object it’s picking up).
Alright, then. I was asking a different question though, but it’s fine.
So I’m currently experimenting with a mouse over sensor and a “hitObjectList” property in python. I’m trying to make the mesh be replaced by simply making the mesh replace itself, but with the mesh that the mouse is over(the object it’s picking up).
Well lets start at the beginning then.
No, you can not receive messages with python without using the message logic brick. However you can send messages with python only.
use mouseOver.hitObject instead of the list, this results in the object the mouse is on, instead of generating a list that the mouseover detects. Then on click(or whatever you like) you end the object(if needed), at the same time you grab the data from that object (a property with the new mesh name). So you grab that property then with that property you can select the right mesh with replaceMesh(‘the property data’).