Jump to content

Model does not register hit points - created in Unity


poly

Recommended Posts

Hey guys,

I'm attempting to make my very first mod and it's going quite well - I'm now comfortable with xml thanks to watching Max Fox's youtube playlist and I've got to the point where I'm learning Unity to create my own blocks/integrate free assets into the game.

However, I've encountered a problem that I have tried to solve for 3 days - any help would be appreciated. Perhaps someone with more knowledge of Unity than me - I'm at pre-beginner level ☺️

 

So I have an object, it's a tree, and made the xml to display it in the game. It works fine without errors.
However, when I punch the tree nothing happens. I can't walk through the tree so collision is working okay, but it doesn't register my interaction with it.

My Unity parent-child looks like this:

parent:
spacer.png

 

child:
spacer.png

 

Can anyone see any obvious reasons as to why it won't register hit points?

The xml is working fine - to test this I just change the model to a basic 1x1 cube I created and it works okay so I don't know what the issue is.

Many thanks!

 

Link to comment
Share on other sites

Are you using the official tag manager or did you manually add tags into Unity?  If your not using the full tag manager, which is available in my tutorial project or in my templates repo, then that's one explanation.  Another is try removing the t_block tag, as that might be blocking the correct T_Mesh_B tag on the child with the collider.  You could use the T_Block tag, but not on the default layer like you have it.

Link to comment
Share on other sites

On 8/18/2021 at 8:24 PM, xyth said:

Are you using the official tag manager or did you manually add tags into Unity?  If your not using the full tag manager, which is available in my tutorial project or in my templates repo, then that's one explanation.  Another is try removing the t_block tag, as that might be blocking the correct T_Mesh_B tag on the child with the collider.  You could use the T_Block tag, but not on the default layer like you have it.


Hi!

Thanks for the reply!

I will give both suggestions a try

Link to comment
Share on other sites

I reverted to your template and built a tree from that point - the meshing works fine now! Not sure exactly what the problem was, perhaps the t_block tag like you said.

I'm trying to make 2 versions of 1 tree by using the scale transform tool but they both appear at 1:1 scale in game, despite one being at 0.5, any ideas on why?

PS thanks for all of your tutorials on here, they've really helped a lot!!!

Link to comment
Share on other sites

On 8/26/2021 at 7:32 PM, xyth said:

if you do scaling in unity, make sure you scale a child object and do not mess with the top parent object.  Its preferable to scale a copy of the .fbx file before importing, but both methods work

 

 

I'm having the same issue with scaling.

I made 2 new blocks, one is scale 1:1:1 and the other is 0.5:0.5:0.5, so in theory one should be half the size of the other.

If I use the following in my xml the blocks appear as they should do - one half the size of the other:
 

<property name="Model" value="#@modfolder:Resources/test.unity3d?test.prefab"/>


But I have the original problem described - can't interact with the blocks - punch them and nothing happens.

test.prefab in this case is the parent

However, if I call the child:
 

<property name="Model" value="#@modfolder:Resources/test.unity3d?child.prefab"/>

 

I can interact with the blocks, but they both appear at scale 1:1:1.

 

Can anyone replicate this and see if is user error? I don't know what I'm doing wrong haha

Link to comment
Share on other sites

Make sure the tags are on the child with the collider. 

 

And it's always a good idea to use unique names for bundle and prefab names. Having a bundle with a prefab that shares its name will probably cause you some issues. But even having the prefab named the same as the fbx it comes from can cause weirdness. 

Link to comment
Share on other sites

19 hours ago, bdubyah said:

Make sure the tags are on the child with the collider. 

 

And it's always a good idea to use unique names for bundle and prefab names. Having a bundle with a prefab that shares its name will probably cause you some issues. But even having the prefab named the same as the fbx it comes from can cause weirdness. 


I have tested it multiple times with different names - I was thinking this too, but each time gives the same results.

I will keep playing around with it and see if I can get it to work

Link to comment
Share on other sites

23 hours ago, bdubyah said:

Can you post a pic of what it looks like in Unity? And does it look right when you are holding it before you place it? Like, it's lined up and everything and not outside the ghost lines?


Thanks for the reply

I have attached 2 screens from Unity - parent and child.

1 of the relevant xml segment

and 2 of the model - 1 prior to placement and 1 after, having punched it once to show I can interact with it.

The problem is that the tree should be 10% of the scale, but it is 100% - unscaled.
 

<property name="Model" value="#@modfolder:Resources/Tree01.unity3d?Palm01.prefab"/>


Unity filename: Tree01.unity
Parent name: Tree
Child name: Palm01
 

1.jpg

2.jpg

3.jpg

4.jpg

5.jpg


However,

If I call the parent in the xml instead of the child the model displays as intended, BUT I cannot interact with it.
 

<property name="Model" value="#@modfolder:Resources/Tree01.unity3d?Tree.prefab"/>


This is where the confusion lies

 

6.jpg

7.jpg

Link to comment
Share on other sites

The last method is the correct way. The reference is to bundlename.unity3d/topparentname.prefab. So the first way where you use Tree01.unity3d?Palm01.prefab is wrong.

 

Tree01.unity3d?Tree.prefab would be correct. And from what I can see from those screens, the Palm child has the collider, but isn't tagged. You want to tag the child that has the collider. I don't even see the tag area in the inspector on that part, so not sure what's going on there. But that is probably your issue.

Link to comment
Share on other sites

On 9/4/2021 at 12:34 AM, bdubyah said:

The last method is the correct way. The reference is to bundlename.unity3d/topparentname.prefab. So the first way where you use Tree01.unity3d?Palm01.prefab is wrong.

 

Tree01.unity3d?Tree.prefab would be correct. And from what I can see from those screens, the Palm child has the collider, but isn't tagged. You want to tag the child that has the collider. I don't even see the tag area in the inspector on that part, so not sure what's going on there. But that is probably your issue.


I have amended all xml to the correct syntax calling the topparentname and added the T_Mesh_B tag to the child with the collider.

In testing before I place the block it displays as the correct model with the correct scale, but when I place it down they all revert to 0.1 scale, also they don't grow to the next stage - I have growthrate as 2 for testing purposes. And I can't interact with them again - as if the collider isn't there anymore

🙃

Link to comment
Share on other sites

  • 1 month later...
On 10/21/2021 at 3:31 PM, poly said:

Still not found a fix for this. Does anyone else have any suggestions? Or a possible workaround? I basically want to have a tree appear different sizes in 4 growth stages. Scaling doesn't seem to work for me.

 

 

Hi Poly

 

I do not know practically anything about unity, but from what I have seen some property is missing in the Xml, but I do not know if that is the solution to your problem.
Like Bdubyah, the model that you put as the seed, it is wrong because a large tree appears, instead of the small palm.
These are the possible missing properties, but since it extends from treeMasterGrowing they shouldn't be a problem.

 

<property name = "FilterTags" value = "foutdoor, ftrees" />
<property name = "SortOrder2" value = "0120" /> <! - SortTree ->

 

If you could provide the blocks.xml file for a look, it would be a great help.


Regards

Link to comment
Share on other sites

I tried replacing only the 'model' property with a different unity3d file and it works fine which is why I think the problem is within Unity, not xml.

For example, if I leave the xml as it is and change
 

<property name="Model" value="#@modfolder:Resources/Tree01.unity3d?Palm01.prefab"/>


To
 

<property name="Model" value="#Entities/Trees?Birch55Prefab.prefab"/>


Which is the deprecated Birch tree. It all works fine. The tree grows through all stages and I can interact with it.

However, for testing purposes I will try adding the properties you mentioned above and report back the results

Link to comment
Share on other sites

41 minutes ago, poly said:

I tried replacing only the 'model' property with a different unity3d file and it works fine which is why I think the problem is within Unity, not xml.

For example, if I leave the xml as it is and change
 

<property name="Model" value="#@modfolder:Resources/Tree01.unity3d?Palm01.prefab"/>


To
 

<property name="Model" value="#Entities/Trees?Birch55Prefab.prefab"/>


Which is the deprecated Birch tree. It all works fine. The tree grows through all stages and I can interact with it.

However, for testing purposes I will try adding the properties you mentioned above and report back the results



I've just added both lines to all 4 blocks and tested it out in a new world and still have the same issue - it has to be within Unity.

Irony is at some point I had it working. So it older versions of my mod I have a tree a full scale which works and one at 10% scale which works, within the same xml block. 
However, I've read and watched so many tutorials on Unity and tried about 5 different versions and export scripts that I don't remember which one I used to create the working versions.
It's a shame there's no way you can import a Unity3d file back into Unity so I could look at the settings. I bet it's something really simple.

Link to comment
Share on other sites

Okay, here's what generally works for me in bringing new blocks in from Unity. 

1. I put my meshes and textures in a folder in Assets, set up my materials in the same folder, etc.

2. I create a new GameObject in the Hierarchy panel, and make sure that the values are reset to 0, 0, 0. Let's call it Tree_New_1_prefab.

3. Name the new GameObject what you want you'll be calling from xml. Nothing that you do to this top level GameObject will carry over into 7D2D, I believe.

    This has been my downfall more than once. If you scale your model on this level, it will look fine in Unity but be unscaled when you place it in 7D2D (it will, however, appear in the expected size until you complete placing it--sound familiar?) If you tag this level with T_Mesh_B, you still won't be able to interact with it in 7D2D, even if you put a collider on it.

4. Drag a copy your model from Assets and put it into your new GameObject. This model/subfolder is where you have to do all your scaling, attach your collider,  and put your T_Mesh_B tag.

5. If you want a differently scaled version of the same tree, make a duplicate of the GameObject, rename the new GameObject to Tree_New_2_prefab, and do the scaling on the model/subfolder. Rinse and repeat until you have your 4 versions of the tree.

6. At this point, I usually create an empty folder in Assets, say "Finished Trees," and drag the four GameObjects into it, one at a time. Select the four GameObjects in "Finished Trees," right click, and export. Name your file something like "MyTrees.unity3d"

7. Define your new blocks in the blocks.xml, and call them with

<property name="Model" value="#@modfolder:Resources/MyTrees.unity3d?Tree_New_1_prefab"/>

and so on, for Tree_New_2, 3, and 4.

 

That's always worked for me. Hope it works for you, too.

 

Link to comment
Share on other sites

11 hours ago, Cranberry Monster said:

Okay, here's what generally works for me in bringing new blocks in from Unity. 

1. I put my meshes and textures in a folder in Assets, set up my materials in the same folder, etc.

2. I create a new GameObject in the Hierarchy panel, and make sure that the values are reset to 0, 0, 0. Let's call it Tree_New_1_prefab.

3. Name the new GameObject what you want you'll be calling from xml. Nothing that you do to this top level GameObject will carry over into 7D2D, I believe.

    This has been my downfall more than once. If you scale your model on this level, it will look fine in Unity but be unscaled when you place it in 7D2D (it will, however, appear in the expected size until you complete placing it--sound familiar?) If you tag this level with T_Mesh_B, you still won't be able to interact with it in 7D2D, even if you put a collider on it.

4. Drag a copy your model from Assets and put it into your new GameObject. This model/subfolder is where you have to do all your scaling, attach your collider,  and put your T_Mesh_B tag.

5. If you want a differently scaled version of the same tree, make a duplicate of the GameObject, rename the new GameObject to Tree_New_2_prefab, and do the scaling on the model/subfolder. Rinse and repeat until you have your 4 versions of the tree.

6. At this point, I usually create an empty folder in Assets, say "Finished Trees," and drag the four GameObjects into it, one at a time. Select the four GameObjects in "Finished Trees," right click, and export. Name your file something like "MyTrees.unity3d"

7. Define your new blocks in the blocks.xml, and call them with

<property name="Model" value="#@modfolder:Resources/MyTrees.unity3d?Tree_New_1_prefab"/>

and so on, for Tree_New_2, 3, and 4.

 

That's always worked for me. Hope it works for you, too.

 


Thanks for taking the time to go through your own process with Unity, really appreciate it!!!

I tried the method you use and sorted out the scaling issue - thanks!

However, the interaction issue in-game still persists. So, as things are, I can place the blocks in the game and they appear as I want them to appear - if I approach them I can't walk through them so the tagging appears to be working.

But I punch it and nothing happens - it's as if I'm punching air. Hitting it with anything, chainsaw, axe etc is the same - it's as if it's not there.

As a test I replaced only the model line in the xml with another block which I use - the block of another tree used from a different mod which I use for testing. It works when I do that - so I know it's not an xml problem.

I have no idea what else to try!!!

For what it's worth the palm tree model I'm trying to use is one from this free asset

 

Link to comment
Share on other sites

I don't believe it I've just fixed the problem!!!

Just out of curiousity I placed the model directly into the left panel - not inside a GameObject folder - and then dragged the model into the bottom panel for export - it works!!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...