spawn a complicated object
20 posts • Page 1 of 1
spawn a complicated object
is it possible to spawn a complex object? like a polygon. or a shape normally made with the brush tool? if there is than i have a creepy idea for a scene. seriously is there an oncollide code that can do this.
canadian joe wrote:im just writing this so i can sig it
RicH wrote:Phun's Army.
-
canadian joe - Posts: 115
- Joined: Wed Feb 10, 2010 9:42 pm
Re: spawn a complicated object
Yes it is. But you can spawn much more complex things than just a polygon. You can for example spawn a whole scene with an onCollide script
For polygons you have to define the surface.
That's the basic script. Of course you can also add the spawning position or color or whatever. [xi, yi] is the i-th surface position.
For polygons you have to define the surface.
- Code: Select all
scene.addpolygon({ vecs := [[x1, y1],[x2, y2],[x3, y3],...[xn, yn]]; })
That's the basic script. Of course you can also add the spawning position or color or whatever. [xi, yi] is the i-th surface position.
Last edited by KarateBrot on Sat Feb 20, 2010 3:20 pm, edited 2 times in total.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: spawn a complicated object
is there a script code to spawn a hand shaped thing that would normally be made with a brush tool.
canadian joe wrote:im just writing this so i can sig it
RicH wrote:Phun's Army.
-
canadian joe - Posts: 115
- Joined: Wed Feb 10, 2010 9:42 pm
Re: spawn a complicated object
For example:
Will spawn a 4-sided polygon at position [0,0]
Check this scene out. Maybe it helps.
Well, I thought about it but it's maybe too advanced...
- Code: Select all
scene.addpolygon({ vecs := [[2,2], [-1,1], [-1,-1], [1,-1]]; pos := [0,0] })
Will spawn a 4-sided polygon at position [0,0]
Check this scene out. Maybe it helps.
Well, I thought about it but it's maybe too advanced...
Last edited by KarateBrot on Sat Feb 20, 2010 3:16 pm, edited 1 time in total.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: spawn a complicated object
cool. now i just need to modify this to be all hand shaped for my scene.
canadian joe wrote:im just writing this so i can sig it
RicH wrote:Phun's Army.
-
canadian joe - Posts: 115
- Joined: Wed Feb 10, 2010 9:42 pm
Re: spawn a complicated object
Yes, that's a lot of work if you do it by hand and if you have very much surface points. You could make it automatic with a function but that's maybe a bit too advanced.
But what you can do is to make a polygon with your drawing tool. Then you just have to select the polygon and press CTRL + C. In a text editor you have to press CTRL + V and you get all coordinates.
But what you can do is to make a polygon with your drawing tool. Then you just have to select the polygon and press CTRL + C. In a text editor you have to press CTRL + V and you get all coordinates.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: spawn a complicated object
that sound much easier. i started doing it be hand and it really is kinda trial and error plus there would be alot o points to made a decent shaped hand.
canadian joe wrote:im just writing this so i can sig it
RicH wrote:Phun's Army.
-
canadian joe - Posts: 115
- Joined: Wed Feb 10, 2010 9:42 pm
Re: spawn a complicated object
wow i think you were right. this is kind of complicated. i can get all of the points onto a text thing like you said. then pasted them where the normal points should be. i even made sure that i pasted in between the begining and the end of th e script. by this i mean that beforehand i finished the script with the )s and} that made sence and then added the points befor thos so it looked like ({ vecs := (points) }) but for some reason it still wont work. i am sad so now i cannot spaw those lower arm things that ragdolls have
canadian joe wrote:im just writing this so i can sig it
RicH wrote:Phun's Army.
-
canadian joe - Posts: 115
- Joined: Wed Feb 10, 2010 9:42 pm
Re: spawn a complicated object
are you sure you didn't forget any brackets or commas or something else?
Be sure to make [ ] brackets around all your points => [ [2,2], [-1,1], [-1,-1], [1,-1] ]
Be sure to make [ ] brackets around all your points => [ [2,2], [-1,1], [-1,-1], [1,-1] ]
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: spawn a complicated object
Actualy, there are two sets of brackets [[ [0,1],[0,0],[1,0],[1,1] ]]
That should work.
And I made a scaner / spawner that reads shapes and spits them out, it uses a polygon spwn code.
Here, I'll upload it.
That should work.
And I made a scaner / spawner that reads shapes and spits them out, it uses a polygon spwn code.
Here, I'll upload it.
-
Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: spawn a complicated object
the important thing is to have a 2 dimensional array (an array with arrays in it). two sets of brackets make it a 3 dimensional array. you will get an error message.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: spawn a complicated object
Huh, I always have to have two sets, it won't work otherwise,.
Yes, i just checked it.
Look at the scipts for putting the array together, it has 2 at the begining and the end, without it it gives an error message saying not a real list.
Yes, i just checked it.
Look at the scipts for putting the array together, it has 2 at the begining and the end, without it it gives an error message saying not a real list.
-
Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: spawn a complicated object
Hmm yeah, indeed. Maybe it has something to do with your use of eval or something different because normally you get an error message if it's not a two-dimensional array. Maybe you have to add an extra pair of brackets because they get removed/ignored somewhere in a function so at the end you get a two-dimensional array and no three-dimensional one. after looking at different error messages with different numbers of brackets i am pretty sure it has something to do with it.
besides: you made a very complicated scripting part. it can be done MUCH easier but nice one for going the complicated way
besides: you made a very complicated scripting part. it can be done MUCH easier but nice one for going the complicated way
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: spawn a complicated object
for some reason my ctrl+C ctrl+v isn't working anymore. it used to work but now nothing is happeneing
canadian joe wrote:im just writing this so i can sig it
RicH wrote:Phun's Army.
-
canadian joe - Posts: 115
- Joined: Wed Feb 10, 2010 9:42 pm
Re: spawn a complicated object
Some people seem to have that problem. As far as I know, there's no fix.
TheWinkits wrote:They both looks of cuking amazing
-
Chronos - [Most Active Member 2010]
- Posts: 4457
- Joined: Mon Aug 31, 2009 6:00 pm
- Location: Californania
Re: spawn a complicated object
it works! now i have a script that spawns a polygon. how do you set it's size?
canadian joe wrote:im just writing this so i can sig it
RicH wrote:Phun's Army.
-
canadian joe - Posts: 115
- Joined: Wed Feb 10, 2010 9:42 pm
Re: spawn a complicated object
the vecs that you put in determin the size of the polygon
-
Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
Re: spawn a complicated object
jup you should do that already in the vecs that's the best way. but if you want to scale the polygon you still can multiplicate the vecs with a factor to make the polygon bigger/smaller.
For example to make it double sized
For example to make it double sized
- Code: Select all
scene.addpolygon({ vecs := 2*[[2,2], [-1,1], [-1,-1], [1,-1]]; pos := [0,0] })
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: spawn a complicated object
thanks! you are a big help to this!since i am an amateur scripter this is very helpful
canadian joe wrote:im just writing this so i can sig it
RicH wrote:Phun's Army.
-
canadian joe - Posts: 115
- Joined: Wed Feb 10, 2010 9:42 pm
20 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 12 guests