Spawning fixed objects
6 posts • Page 1 of 1
Spawning fixed objects
Is there a way I can spawn 2 squares and have them fixated together?
Like a shotgun ejecting a shotgun shell having yellow at the bottom fixated to a red shell
Thanks!
Like a shotgun ejecting a shotgun shell having yellow at the bottom fixated to a red shell
Thanks!
- theclankinator
- Posts: 7
- Joined: Wed Jul 29, 2015 1:29 am
Re: Spawning fixed objects
You can use this code to create a fixjoint
- Code: Select all
scene.addFixjoint({
geom0 := ;
geom0pos := ;
geom1 := ;
geom1pos := ;
size := ;
})
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: Spawning fixed objects
This code will spawn something like a shotgun shell. It might not look like you wanted but if you upload your shotgun shell, I can make a script that spawns an exact copy of it.
- Code: Select all
Scene.addBox({
size := [2, 1];
color := [0.76, 0, 0, 1];
pos := [-1, 2.5];
geomID := 1
});
Scene.addBox({
size := [0.375, 1];
color := [1, 1, 0.05, 1];
pos := [-1.8125, 2.5];
geomID := 0
});
Scene.addFixjoint({
geom0 := 0;
geom0pos := [0, 0];
geom1 := 1;
geom1pos := [-0.8125, 0];
size := 0.2;
color := [0, 0, 0, 0]
})
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: Spawning fixed objects
Thats perfect! Thank you!
- theclankinator
- Posts: 7
- Joined: Wed Jul 29, 2015 1:29 am
Re: Spawning fixed objects
T'wind_ wrote:This code will spawn something like a shotgun shell. It might not look like you wanted but if you upload your shotgun shell, I can make a script that spawns an exact copy of it.
- Code: Select all
Scene.addBox({
size := [2, 1];
color := [0.76, 0, 0, 1];
pos := [-1, 2.5];
geomID := 1
});
Scene.addBox({
size := [0.375, 1];
color := [1, 1, 0.05, 1];
pos := [-1.8125, 2.5];
geomID := 0
});
Scene.addFixjoint({
geom0 := 0;
geom0pos := [0, 0];
geom1 := 1;
geom1pos := [-0.8125, 0];
size := 0.2;
color := [0, 0, 0, 0]
})
Is there a way I can make the pos relative to a certain box?
So instead of the pos being [-1, 2.5], can I make it be pos := pos?
I played around with it a bit and the second geom just attached to the center of the first
- theclankinator
- Posts: 7
- Joined: Wed Jul 29, 2015 1:29 am
Re: Spawning fixed objects
Is there a way I can make the pos relative to a certain box?
So instead of the pos being [-1, 2.5], can I make it be pos := pos?
Yes, you can do it with pos := pos
I played around with it a bit and the second geom just attached to the center of the first
geom0pos is the position of the fixjoint relative to the center of geom0 and geom1pos is the position of the fixjoint relative to the center of geom1. So if you write geom0pos = [0, 0]; geom1pos = [0, 0] the center of the first box will be attached to the center of the second. If you write geom0pos = [-1, 0]; geom1pos = [1, 0] the right side of the first box will be attached to the left side of the second box. Note that the first box is geom1 and the second geom0.
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
6 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 16 guests