View Full Version : Spawning Object
17th Feb 2007, 1:10 PM
Well I am currently making a working gun. 1 of the main things of it, is it will have a case. Anyway, instead of animating the top of it, I decided to do it an easier way. :bunny: Well I thought of doing it by deleting the original closed mesh and spawning the other open mesh in the same position to make it look like it opens. I can get the original one to delete, but I am having trouble with the other one spawning in the same spot. I am making it spawn on top of the other mesh, but it doesn't seem to be working. Anyway, I am certain I am doing it the wrong way and was wondering if anyone knew a way around it? :blink:
17th Feb 2007, 1:40 PM
Seems like I can't edit the thread, so I'll show you a pic in this reply. People will be able to understand a little more with a pic of the case thing.
17th Feb 2007, 11:42 PM
Trust me, that's *not* an easier way. ;)
If you really don't want to fuss with animations, try loading a second GMDC with the "open" mesh into your object, then switch the meshes at the necessary point. :) You can see this in action in the counters, but there's a simple example in the init of the "Genetically Engineered Water Lillies".
For reference though, the reason you cannot spawn a new briefcase over the top of the other is that (1) your objects do not allow intersections, and (2) You have the case in a table slot in the above picture, and a table slot can only ever hold one object. When you spawn another object, you can't spawn in in the same slot because it's already occupied, and you can't spawn it on the same tile because that would break the intersection footprints. In any case, even if you were able to have them spawn directly on top of each other, you have to write some thoroughly irritating code to make sure that they are facing the same way.
Points for creative problem solving though! Some of the best tricks come out of "how can I avoid doing 'x'?
18th Feb 2007, 4:59 AM
Thanks Echo :)
18th Feb 2007, 6:29 AM
Well I can't make much sense from the coding in the plant, except the random number node and the one after. It seems to be setting it to the next one. What I was wondering, was if Temp 0x000 refers to the GMDC or does it have to be set that way? Or am I wrong on my suspection? :blink:
18th Feb 2007, 11:10 AM
Assuming that "My" is the object you're trying to change the mesh for, then "My Graphic" refers to which mesh the object is currently displaying.
You need two GMDCs. You enter the names of each of these into the Mesh text list (can't remember which one it is, but it'll be there already with the name of your existing GMDC). Then, setting My Graphic := [Line in the text list with the name of the GMDC that you want] will switch the mesh over. :)
Edit: The "random then add one" step is choosing which random mesh to display. The "random" call will only generate a number from 0 to (x), but the lines in the mesh list start at 1. Thus the need to add 1. (eg - get random 0..3, add 1, you now have a number from 1..4)
18th Feb 2007, 11:26 AM
Just a quick question, after it changes the mesh and I exit the game, the next time I go in, will the mesh change back to the original or stay the same? Because I noticed that the texture change on the sword stand does that.
18th Feb 2007, 11:33 AM
Stays the same. The game maintains the "My Graphic" automagically. :)
18th Feb 2007, 11:43 AM
lol, ok, Thanks Echo for the help. :D
18th Feb 2007, 12:32 PM
Ok, for the GMDC, I guessed that I would have to clone the GMND, the CRES and SHPE also. I cloned all 4, renamed them and pressed, fix tgi and went and did a fix integrity. When I click preview in the first GMDC, it says "The parent CRES was not found. This means, that SimPE is unable to build the Joint Hirarchy". But the preview still shows. I was wondering if these 4 files are linked together in some way besides the name and if I need to do that? and if that error is something to worry about?
19th Feb 2007, 9:28 AM
You're right, you do need to clone the other parts as well. Fix Integrity should fix TGI by itself btw. There should be references inside the files connecting them up, did you update those as well? Is there any chance of posting it? I'm no diagnostician when it comes to the interconnections of meshes, but it does help to look at the object. :)
19th Feb 2007, 9:46 AM
Ok, here's the file :) The coding from my original plan is still there, So it hasn't been coded to change the mesh... yet! ;) And I had a try at linking the other mesh to the texture, but seems unsuccessful :p
19th Feb 2007, 11:09 AM
Well that was an entertaining learning experience. :) The error has gone when you preview the mesh and the scenegraph looks properly conncted now at any rate. Can't tell you if it's all set up for the mesh switching yet, because as you noted that part isn't coded yet!
- In the CRES, the reference tab lists the TGI for the SHPE file. Change the sub type field to the "Instance (High)" of the new shape, and the instance field to the "Instance" of the new shape.
- In the SHPE, under the "items" tab, change the name to the name of your new GMND.
- In the GMND, the reference tab lists the TGI for the GMDC. Change the Sub Type and instance to the values for the GMDC (like in the first dot point).
I think that's all I did anyway. There may have been other things, there was certainly some fiddling involved. :)
19th Feb 2007, 11:20 AM
Thanks Echo, that'll definately help when I want the sim to add a laser sight. :D You're a modding god. ;)
19th Feb 2007, 4:11 PM
Ok, well it's seems to be not working. At first I thought it was going through the false line, but I turned that into an error and got no error report. So, I think it's either that I have the name wrong in the text lists, or when it is thinking of "My Graphic", it is refering to the sim. I'll attach 2 pics, 1 of how the file seems to be set up and the second of bhav which should set "My Graphic" as the object, instead of the sim. (Is that correctly done?)
19th Feb 2007, 4:33 PM
I just tested that out ingame and no luck with it. :(
20th Feb 2007, 9:47 AM
Heh, yeah, that code doesn't look quite right. Replace those two lines with:
Stack Object's Graphic := Literal 0x02
Because it's in an interaction, "My" is the sim, not the object. (points to the first line in post 6 of this thread ;)).
20th Feb 2007, 11:41 AM
It worked!!! Thank you Echo :D :D :D :D :D
21st Feb 2007, 10:27 AM
Congrats! I've never actually tried to do it myself, so well done on getting it to work!
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.