Newbie Question

Posted By: A.Russell

Newbie Question - 05/20/04 21:36


Physics has never been my strong subject, but I'd like to have a go at some physics scripting.

Would it be possible to use physics to simulate the small steel balls in a pachinko machine. There would be quite a lot of them boununcing around at one time.
Posted By: elsewood

Re: Newbie Question - 05/21/04 00:12

aum 25
Posted By: A.Russell

Re: Newbie Question - 05/21/04 11:31



Wel, that's a good start for coding the ball behaviour. Thanks for pointing that out.

I'll still need a lot of balls though. Could the engine handle several hundred balls at a time?
Posted By: Marco_Grubert

Re: Newbie Question - 05/21/04 12:24

Quote:

Could the engine handle several hundred balls at a time?


Depends on the target system. Spheres are very "lightweight" physics objects but if you have tons of them and also a lot of pins in the machine then collision detection might be slow.
Posted By: A.Russell

Re: Newbie Question - 05/21/04 15:01


Okay, thanks. I'm just in the very early design phase on this one. So if anyone has some experience with putting lots of bouncing balls in their game, please let me know what would be a realistic number to have going at one time.

Ideally I'd like every ball in the machine to have a physics action, but that could be thousands. If only the ones that are on the playing board at one time, then proabably less than 50. There would need to be quite a few pins on the board for them to bounce off as well. See illustration:


Posted By: Marco_Grubert

Re: Newbie Question - 05/22/04 04:41

Really, just take the AUM25 example and change a couple of lines so that you can add more spheres at random times. This takes less than 30 minutes of coding and you can see if the results are okay or not (btw you also want to set friction to 0 and maybe lower ph_fps_max_lock to less than 70 for better performance).
Posted By: Marco_Grubert

Re: Newbie Question - 05/25/04 07:27

Have you tried it ?
Posted By: A.Russell

Re: Newbie Question - 05/25/04 22:08



I just downloaded Newton Physics two days ago. Tuesday is my hell day at work when I have to work 12 hours, so I didn't get anything done today. I'm also being hounded to write a couple of tutorials.

Also, I'm considering using the pysics in the pro version of 3dgs. I was going to upgrade for some other features soon anyway. If anyone can shed some light on which way is the best to go right off the bat would be helpful (and if it even matters).

In physics class at school I spent more time staring at the walls than studying my books (so you see, these things really can turn out to be useful to you later in life).

I will try it very soon though, and post again.
Posted By: fastlane69

Re: Newbie Question - 05/26/04 04:18

<------Physics Professor at your disposal.

Honestly Russ, if I weren't so busy myself, I would whip this up for you.
This is really a trivial affair with the 3DGS PE and should be just as easy with the NGD.
In my MMO project, I had 100 physics objects running at the same time before things slowed down. I think this is plenty of Steel Balls to simulate what you want.

I'll be more than happy to help you with the 3DGS PE and with the RL PE.


"Ask Dr. Know. Theres nothing I don't!"
Robin Williams in "AI"
Posted By: A.Russell

Re: Newbie Question - 05/26/04 13:07



Thanks Fastlane. I will have a try myself first. I want to learn how physics works, and it will be very satisfying to do it myself. If I get stuck or you can improve on my bhest efforts, then I'll take you up on your offer.

I still have some research to do on this (i.e. I'm going to go and play some pachinko), but if the physics really isn't that hard (???), then I could get that part done then come back to the design of the board later.

I don't only want the balls on the playing field moving. One of the most exciting aspects of Pachinko is that when you start winning, you keep winning and balls start spewing out everywhere. (Funny thing is the Japanese one armed bandits do the same thing with coins, but that's another story). Eventually you have buckets of the things. I have to work out a way simulate that. ONce balls come to rest, they won't need a physics action applied to them, and the balls themselves could be represented by 2d sprites.

I put my order in for 3dgs pro this morning.
Posted By: A.Russell

Re: Newbie Question - 06/01/04 20:44



Okay. while I didn't have much to do at work today I planned this pachinko simiulation a little more and read the physics commands in the manual.

Since the entire playing field is no more than 50cm diameter, and there are a lot of small objects, I think the scale should be something like 1 quant = 0.5mm (a pin wouldn't be much more than 1mm diameter in any case).

If the scale were 1q = 0.5mm then gravity would need to be set to -7620 (381*1/0.05 -isn't that right?).

That being the case, should I use geometry for the pins, or entities (set up somehting like ph_settype(pin, ph_rigid, ph_cylinder) ?)

To shoot the balls onto the field, would I create the ball at its start position and use phent_adforcelocal()? This command is difficult for me to understand ,so some light on how this could be made to work would be useful.

I have no idea what the mass of a pachinko ball would be. I'll try and ask someone.

There are spinners in the machine too. I haven't got to thinking about how they would be made to act.

Firstly, if you physics' gurus could tell me if I'm on the right track so far as regards scale, I can go ahead and make a playing field for testing.
Posted By: fastlane69

Re: Newbie Question - 06/02/04 10:00

The overriding theme to this reply:

Don't rely on physical numbers to guide you but only to inspire you. Rather, manually vary all the settings till it looks and feels good or right or appropriate.


Quote:

Since the entire playing field is no more than 50cm diameter, and there are a lot of small objects, I think the scale should be something like 1 quant = 0.5mm (a pin wouldn't be much more than 1mm diameter in any case).




At this scale, your whole machine will only be 1000 quants wide and each pin would be 2 quants. I would scale up the whole machine so that your pin is at least 10 quants wide. Otherwise, your pins will look like rectagular nails instead of pins and while the PE should be able to handle 1 or 2 quant object collision, it's asking for trouble IMO.
Of course I'm not aware of the steel ball dimensions; that plays a factor too.

Quote:

If the scale were 1q = 0.5mm then gravity would need to be set to -7620 (381*1/0.05 -isn't that right?).




It would actually have to be set to -19.6 kq/s/s.

[ (1q) / (.5 mm) ] * [9800 mm/s/s] = 19600 q/s/s

My advice with gravity is though don't use physical numbers. Tweak it manually till it "looks" and "feels" right...it's not the real world inside your computer, so why be bound by it's numbers.

Quote:

That being the case, should I use geometry for the pins, or entities (set up somehting like ph_settype(pin, ph_rigid, ph_cylinder) ?)




Go with a larger pin size as above and use cylinder. Otherwise, any should do.

Quote:

To shoot the balls onto the field, would I create the ball at its start position and use phent_adforcelocal()? This command is difficult for me to understand ,so some light on how this could be made to work would be useful.





I'm going to assume that you launch the balls like in a pinball machine, spring loaded.

phent_addforcelocal takes two vectors. The first one tells you the direction you want to apply the force (up, down, left, right since this is local....n, s, e,w if this was addforceglobal). The second vector tells where to apply this force. For our purposes, leave this as a nullvector since we want to apply the force dead center to the ball. HOwever, putting a off center value to the second vector will lead to spin, which is not an entirely bad thing!

Ok now, put your ball in it's chute. The player can select to stretch the spring back to 5 diffrent positions (this discritization makes it easier on us to code and easier on the animations). 1 is a slight pull back. 5 is a pulled back all the way.
the only diffrence between these setting is the amount of TIME you apply addforcelocal
Thus, you would constantly apply (through a loop...won't do it automatically) a addforcelocal for say 1 sec up to 5 secs. Naturally, the 5 sec ball has had more momentum imparted on it and thus shoots off fast. The 1 sec ball hasn't had as much time to gain momentum and thus comes out slower.

Quote:

I have no idea what the mass of a pachinko ball would be. I'll try and ask someone.






I would guess it at under 50 grams. Maybe under 20 grams.
BUT, like my gravity advice, don't be ruled by physical numbers. The player will have NO idea what the gravity setting is nor what the mass settings are..they will equate bigger with heavier and things of the same volumen and material as being the same mass and that's enough for player immerssion! Look up the mass, but honestly, just manually tweak it till it looks good.

Quote:

There are spinners in the machine too. I haven't got to thinking about how they would be made to act.




Digest the above and then we'll move to contraints. A spinner will not be difficult at all.


(PS: lose the yellow virtual world...one can harldly read it and yellow is a HEADACHE color in my book.... )
Posted By: A.Russell

Re: Newbie Question - 06/03/04 00:10

This physics thing is fun


Thanks Fastlane. I threw a level together today. As you suggested I used a very small scale of 1 quant=0.1mm.

However, I've run into a couple of problems.

The collision detection is terrible. Even though the walls are at least ten quants thick, the ball often goes through them. It doesn't even seem to matter what speed the ball is travelling at.

The ball performs better when I use a spherical model. When I try using a sprite, even though I have set it to behave like a sphere, it doesn't. Also, when it gets in a narrow place, it sometimes slows down then speeds up again -not very realistic.

I have another problem with the GSjanFX plugin, but that is a different story, and I'll post elsewhere.

in the meantime here is the code I threw together for testing:

Code:
// pachinko2.wdl



path "C:\\Program Files\\GStudio6\\template"; // Path to WDL templates subdirectory

include <GSjanFX.wdl>;

var ball_pos[3];


//function declarations
function create_ball();
function init_sphere();
function init_pin();
function set_pins();





//string pachinko2_wmb = <pachinko2.wmb>;


function main()
{
level_load ("pachinko2.wmb");
wait(3);


camera.x = 0;
camera.y = -6500;
camera.z = 1500;
camera.pan = 90;
ball_pos.x = 900; // initial value, ranges from -95 to 105
ball_pos.y = 0;
ball_pos.z = -750;

// set_pins();
create_ball();
}





//entity* ball_ptr;


function create_ball()
{

ent_create("pachi_ball.mdl", ball_pos, init_sphere);



}

function init_sphere()
{
my.scale_x=2.5;
my.scale_y=2.5;
my.scale_z=2.5;
my.pan=90;

phent_settype(my, ph_rigid, ph_sphere);
// Enable physics for this ball; it will behave like a sphere when it comes to collisions

phent_setmass(my, 0.05, ph_sphere);


phent_setfriction(my, 30);
// Friction = 30 (could be 0...100)

phent_setelasticity(my, 60, 0);
// Bounce a little (value = 30, could be 0...100)

temp.x = 0;
temp.y = 0;
temp.z = -360;
ph_SetGravity(temp);
// Set gravity for the sphere (temp.z = -380 corresponds to the earth gravity factor, g = 9.81 m/s2)

//punch ball out shoot
phent_addforcelocal(my,vector(0,20000,0),nullvector);

while (my.z > -1000) {wait (1);}
// Wait until the ball has fallen off playing field

phent_settype(my, 0, 0);
// Now stop the ball; A6 commercial allows us to use one object (ball) at a time

wait(1);
ent_remove(me);
}

function init_pin()
{
phent_settype(my,ph_rigid,ph_cylinder);
}




function set_pins()
{

//this doesn't work properly yet




Posted By: fastlane69

Re: Newbie Question - 06/03/04 08:26

Quote:

The collision detection is terrible. Even though the walls are at least ten quants thick, the ball often goes through them. It doesn't even seem to matter what speed the ball is travelling at.





ROFL. Sorry, not laughing at you, but this is a "classic" 3DGS PE bug/problem. The solution for the time being is to, well, make sure you're balls aren't going fast enough to go through the walls. Also, one thing I found helped me alot was to set the friction of the walls to 0% and elasticity to 100 as well. These "smooth" and "perfectly elastic" walls are less likely to have objects go through them.

Also, I notice you have a 50 "gram" mass(my.mass =.05) for your balls. Again, this is a realistic number, but realistic don't fly to well yet with the PE. Again, to minimize "punching through" a wall, set this mass to at least 10 or 100. Changing your mass won't affect your falling rate as long as you have no drag, so play with that number.(well, rather it shouldn't...i've noticed some discrepancies in this area)

Quote:

The ball performs better when I use a spherical model. When I try using a sprite, even though I have set it to behave like a sphere, it doesn't. Also, when it gets in a narrow place, it sometimes slows down then speeds up again -not very realistic.




I wouldn't mix 2D and 3D objects for collions. STick to the sphere definitly. The slow down in narrow places may be realistic if you consider that your entity was most likely rubbing up against the walls. Set your wall (or ball. the way the PE does friciton, wont' matter) friction to 0 and see if this still happens.


3DGS PE programming IS fun. It gives you almost immediate results and feedback to your works. Once it's stabilized (ie problems you addresses are taken care of), it will be a singular JOY to work with!
Posted By: A.Russell

Re: Newbie Question - 06/03/04 22:34



Thanks for that advice Fastlane, I'll save my level as a map entity and set those characteristics.

The problem with using a 3d ball is that they require a lot of polygons, and to make the light spot on them stay in the right place would no doubt require some kind of shader as well (one I don't even know exists). The pachinko machine requires lots of balls. The bare minimum to be playable is 400, and I want to be able to show the balls in catch basin. A sprite that behaves like a ball is the obvious first choice.

The biggest problem is, the ball isn't even going especaially fast yet, and it can't handle collision. Certainly not as fast as they move in the real machines.

I'm going to try making smaller blocks for the invisible front ofthe machine as well, since that is where the balls most often exit the machine. Perhaps big blocks don't detect collision as well?


@ Marco: What's the story with collision detection? Should it be able to handle fast moving pinballs?
Posted By: fastlane69

Re: Newbie Question - 06/03/04 23:14

FYI, I've only ever had 120 physics objects max on the screen and I think I had the physics clock running in the hundreds of ms; needless to say, the simulation gound to a halt.

400 registered physical objects is, IMO, a bit too much.
I can safely vouch for 100 registered physical ents on screen.
Don't know about the rest of the users.
Posted By: A.Russell

Re: Newbie Question - 06/04/04 02:00



How about if they are just being used for their collision hull (cylindrical pins)? or their elastic, friction-free surface (the level itself)? For the balls that aren't in the playing field, perhaps I could use "Fake Fizziks"?

Anyway, it's all for naught if the collision system can't handle small steel balls wizzing around hitting pins and other small objects (ramps, spinners, rails). At any scale the pins have to be small in comparison to the balls. No pinball simulation is possible without that.

Though I haven't tried scaling the larger sized blocks down yet. Notably the invisable "glass" front.

I have some time tomorrow to test this again.
Posted By: Marco_Grubert

Re: Newbie Question - 06/04/04 08:03

Quote:


How about if they are just being used for their collision hull (cylindrical pins)? or their elastic, friction-free surface (the level itself)? For the balls that aren't in the playing field, perhaps I could use "Fake Fizziks"?



For the balls outside the field just disable physics again: phent_settype(my,0,0); will make my an obstacle for other balls but not move my anymore.

Quote:

Anyway, it's all for naught if the collision system can't handle small steel balls wizzing around hitting pins and other small objects (ramps, spinners, rails). At any scale the pins have to be small in comparison to the balls. No pinball simulation is possible without that.



I think fastlane pointed that out before, you should scale up the whole design for better collision detection, e.g. 10 quants per inch as opposed to the standard 1 quant per inch.

Do the balls penetrate geometry when on their own (e.g. single ball in the machine) or only when pushed there by dozens of other balls?

Quote:

Though I haven't tried scaling the larger sized blocks down yet. Notably the invisable "glass" front.


Use an MDL block set to appropriate scale in WED with visible=off.

If it gets to frustrating just send me a mail with your level and I'll take a look at what is going wrong.
Posted By: A.Russell

Re: Newbie Question - 06/05/04 03:41


Thanks Marco, it did get frustrating, and I have mailed the level.

The most frustrating problem is that the ball always exits the front as if there were no block in the way. The narrow looking chute walls are fine (they are actually ten quants thick in any case). No matter how thick or thin, whatever size, if visible is set or not, if I move it around, it makes no difference. The front block/blocks is always passable (of course I didn't set it passable, it just is).

It also didn't matter if it was a regular level or a map entity. So I think I've exhausted every test before giving in and sending it to you.

I couldn't get the scale much bigger if I wanted to either. It is already at ten quants to a millimeter. I tried making it even bigger, but all it did was make for a much longer build time, and the ball didn't move as naturally anymore with the increased forces I needed to use on it.

Quote:

For the balls outside the field just disable physics again: phent_settype(my,0,0); will make my an obstacle for other balls but not move my anymore.





That's what I was thinking of doing. I see there is a bitmask for enabling and dissabling whole groups of physics entities. I was thinking of putting the balls in the basin in a priority queue depending on how close they are to where they enter the machine, and enabling maybe twenty or thirty at a frame from closest to farthest. That way even there are hundreds in the basin they should all keep moving through.
Posted By: Marco_Grubert

Re: Newbie Question - 06/05/04 07:07

You are running into an issue with the current collision detection. Invisible blocks are not considered obstacles at all. Remove the invisible blocks in your WMP and replace them with a single large MDL cube set to invisible. While you are at it you might also want to change the machine backdrop into an MDL which will increase compile time and FPS, i.e. only leave the slopes and ramps as blocks.

The pins should not be physics entities, since they won't be moving anyway lots of CPU time would be wasted. Instead use regular MDL or WMB entities for them. Looking at the large number of pins you are likely to run into performance problems, using a sprite for the spheres might indeed be a good idea. Try playing with that scale, while larger scale makes collision detection more reliable it also makes it slower due to increased tesselation of level blocks.
Posted By: A.Russell

Re: Newbie Question - 06/05/04 13:29



Thanks, the model for the front glass works. I am not getting any more problems with the balls leaving the board.

However, I still can't use sprites for balls. It's hard to explain. They work, but they don't move as well, and they get stuck in the funnels. Models look natural and go through the funnels without a hitch. For both models and sprites I have the bounding box set to sphere. How do I make sprites perform like the models?
Posted By: fastlane69

Re: Newbie Question - 06/05/04 15:45

Quote:

How do I make sprites perform like the models?




Make them into a model?

The problem you are running into I suspect is that when it comes to collisions, it's all about the contact points. The more points you have, the better the collision. One on One contact point collisions are unpredictable. I have no idea how they implement it, but a sprite will have contat points, by definition, simply "on plane". Thus maybe it has ONE point in the center or FOUR points at the corners (or interstitial) I dont' know, but you will go crazy trying to get a 2D flat surface to collide like a 3D surface.

This is also the reason you want to have a larger quant object to physically register; the larger the object, the more contact points; the more contact points, the stabler the system (though as was pointed out abover, this does cut into performace, thus a balance must be reached between stability and performance).
Posted By: A.Russell

Re: Newbie Question - 06/05/04 19:28



Yes, that must be what is happening, I think the sprites are behaving more like bouncy coins than balls.

It's going to be very difficult to keep the fps up with this.

Anyway, I made some progress today. I'll try and make the spinners tomorrow and maybe redesign the playing field.
Posted By: fastlane69

Re: Newbie Question - 06/05/04 20:49

Just some friendly advice...get your balls and playing field in order before you move on to spinners. I'm assuming that you want to maximize ball count in your project, thus the following scheme might benefit:

Every object you register with the engine will count against a Maximum number of PE registered entities you can field at once and keep the simulation "believable" (never realistic...just believable ). Your "quantum" object, the most basic physical object in your game is the steel ball; thus it seems natural to max out your playing field with no other physical objects and see how many balls you can field at once. This becomes you Bare Maximum.

You can now better analyze each new physical object you wish to introduce (spinners, gates, flippers) as counting against this Bare Maximum. In other words, how many balls would I have to take out to introduce this new physical object and keep my simulation running smooth.

This is not a hard and fast rule but rather something that might make your development a bit easier since it makes no sense to design a feature that has too large an impact on your ball count nor would it make sense to drop a feature if you only lose one or two balls by implementing it.
Posted By: A.Russell

Re: Newbie Question - 06/05/04 21:37



Right now, even forty balls onscreen at one time is pushing it. More than 60 and it will drop below 20fps, which in my opinion is unacceptable.

It's not just the balls. They are not the MOST important thing on the screen (though with a game like pachinko, the more the better, thousands are cool). The balls have to go through things like funnels and spinners to make it interesting, and to make it exciting they have to spit out the winning slot in the thousands!(litterally, when you win at pachinko, you have some big buckets of ball bearings to take to the counter -to take to that completely legal hole in the wall around the corner )

This thousands of winning balls spewing out troubles me, because it so important to the fun aspect of the game. For now I'll just concentrate on the main playing field. Just that is hard enough for now.
Posted By: fastlane69

Re: Newbie Question - 06/06/04 00:05

That's odd. Like I said, I had 100 entities onscreen @ 20fps no problem. Granted they weren't all moving very fast....hmmmm....60 might not be a unrealistic high end.

Here's how we can do this:
Finish the level...tweak it out real nice with all sorts of non-physics bells and whistles....don't do a lick of physics....send me your level balls included...I'LL tweak your physics settings and see if I can't get a few extra balls/fps.
Posted By: A.Russell

Re: Newbie Question - 06/06/04 01:08

Thanks Fastlane,

I think part of the problem is my level geometry. Trouble with BSB is that every damn thing needs to be a block. Once I start cutting into the backface to make holes for the balls to fall through and everything gets cut into triangles and the poly count rockets. I don't really want blocks since very little can really be hidden in this type of simulation anyway. Today, I did push my luck by making the pins eight sided. Realisticly, I think four sided is the minimum. Three sided and there is too much chance of a head on collision. I've had a bit of an attempt to search the internet for other pinball simulation development tips, but it hasn't turned up anything useful yet.

The physics are starting to look realistic. I'm starting to get the right number of balls on the screen and they are moving down at about the rate I'd expect from a real machine. Balls are still getting stuck in blocks (usually they find their way out again, but it looks funny). Balls are still getting stuck in funnels 'even if they are models). Also having a little trouble with SED's debugger showing me changes in some variable s (it doesn't like local variables, and some global ones too -don't know what is going on there).


I'm sure there are work arounds for all these things (dicking the balls when they stop moving, transporting balls in funnels, making goal entities instead of chopping holes...). However the more the physics engine can take care of without resorting to those measures the better. I've seen some pretty cool pinball simulations, and I wonder how they pulled it off.

I'm not going to give it up just yet, and the advice I'm getting from Marco and yourself is greatly appreciated.

Posted By: A.Russell

Re: Newbie Question - 06/06/04 19:31


Things are working much better now. I want to add a flipper to knock the balls out rather than just applying a force directly to them. I'm using a slider for this. I couldn't find an example of setting up a flipper and I'm having a little trouble with it:

Code:
function init_flipper()

{
var constraint1;

phcon_add(ph_slider, my, 0);
ph_con_setparams2(constraint1, vector(50,0,0),nullvector,nullvector); //this gives an error

while(my!=null)
{

temp.x=-spring+random(200)-100;
temp.y=0;
temp.z=0;

//punch ball out shoot
phcon_setmotor(constraint1, temp, nullvector, nullvector);

sleep(1);
}
}


Posted By: fastlane69

Re: Newbie Question - 06/06/04 21:06

This wouldn't be a flipper, it would be the Ball Launcher...maybe they are known as flippers two in the "parlance", I don't know; I never was a pinball wizard



Seems like you haven't set you constraint axis vector:


Code:
 function init_flipper()
{

var constraint1[3]=1,0,0;



phcon_add(ph_slider, my, 0);
ph_con_setparams2(constraint1, vector(50,0,0),nullvector,nullvector); //this gives an error

while(my!=null)
{

temp.x=-spring+random(200)-100;
temp.y=0;
temp.z=0;

//punch ball out shoot
phcon_setmotor(constraint1, temp, nullvector, nullvector);

sleep(1);
}
}


Posted By: A.Russell

Re: Newbie Question - 06/06/04 21:29

Okay, let's call it a ball launcher then. That is a better word. Thanks for that tip, though I'm still having trouble with my ball launcher. It behaves very strangely indeed:

Code:


//Ball launcher

constaint1[3]=1,0,0; //only allows movement on x axis?

function create_ball_launcher()
{
temp.x=ball_pos.x+400; //put in position relativeto where ball is created
temp.y=ball_pos.y;
temp.z=ball_pos.z-130;

ent_create("ball_launcher.wmb", temp, init_ball_launcher);
}

function init_ball_launcher()
{


phent_settype(my, ph_rigid, ph_box);
phcon_add(ph_slider, my, 0);

phcon_setparams1(constraint1, vector(1,0,0),nullvector,nullvector); // I thought that the second agument of this set the contraint axis?
phcon_setparams2(constraint1, vector(-50,0,0),nullvector,nullvector);

while(my!=null)
{

temp.x=-spring + random(200)-100;
temp.y=1600000;
temp.z=0;
//punch ball out shoot
phcon_setmotor(constraint1, temp, nullvector, nullvector);
sleep(0.5);
temp.x-=temp.x;
phcon_setmotor(constraint1, temp, nullvector, nullvector);
sleep(0.5);
}
}




The entity bobs around and spins.

Also, is there a way to stop the entity from spinning?
Posted By: fastlane69

Re: Newbie Question - 06/06/04 22:47

Quote:

Also, is there a way to stop the entity from spinning?




Set phent_maxspeed(linMax,Null) and this will limit the entities linear speed to linMax and it's Rotational speed to Zero.

Quote:

constaint1[3]=1,0,0; //only allows movement on x axis?





That's right...so if your "chute" isn't lined up right, you'll get odd effects indeed.

Quote:

phcon_setparams1(constraint1, vector(1,0,0),nullvector,nullvector); // I thought that the second agument of this set the contraint axis?





I"m sorry Russel...constraint1 is the problem, but I gave you the wrong solution.

constraint1=phcon_add(ph_slider, my, 0);

There that should do it. Forget that constraint vector buisness, you are right; vector() is constraint axis. Sorry for the confusion.
Posted By: A.Russell

Re: Newbie Question - 06/06/04 23:13


constraint1=phcon_add(ph_slider, my, 0);

Heh, I actually had that before. I'll set phent_maxspeed, and with any luck that'll do it.
Posted By: A.Russell

Re: Newbie Question - 06/07/04 18:52

pjhent_setmaxspeed didn't do anything. It still rotates around. When a ball hits the ball luncher, it gets bumped around to the wrong angle, and then goes all to hell bouncing and twirling all over the place.

To tell the truth, I don't understand about things like velocities and torque, so I probably have a few other settings off:

Code:
function init_ball_launcher()

{

var constraint1[3];

phent_settype(my, ph_rigid, ph_box);
constraint1=phcon_add(ph_slider, my, 0);
phent_setmaxspeed(my,10000,null); //this doesn't stop rotation (I tried with other values too)

phcon_setparams1(constraint1, vector(1,0,0),nullvector,nullvector); //limit movement to the x axis
phcon_setparams2(constraint1, vector(-50,0,0),nullvector,nullvector); //can't (shouldn't be able) to move more than 50 quants

while(my!=null)
{

temp.x=-spring;//The amount of force to move the ball launcher
temp.y=-1600000;//maximum force for the ball launcher
temp.z=0
//punch ball out chute
//should make it so that it moves back and forth in 1 second intervals
//seems to work okay until the ball launcher hits a ball and rotates around
phcon_setmotor(constraint1, temp, nullvector, nullvector);
sleep(0.5);
temp.y-=temp.x;
phcon_setmotor(constraint1, temp, nullvector, nullvector);
sleep(0.5);
}
}





Posted By: fastlane69

Re: Newbie Question - 06/07/04 21:23

a) phent_setmaxspeed(my,10000, nullvector );

b) keep constraint1 like you had it before; eliminate all instances of it being a vector (ie replace all constraint1[3] with just constraint1. This is a leftover from my mistaken solution.
Posted By: A.Russell

Re: Newbie Question - 06/07/04 23:39

Okay, I've done those two things. I actually did try it with nullvector, but it didn't work. For a start it does what it is supposed to, but eventually the balls knock the launcher over and it goes wonky:


Posted By: A.Russell

Re: Newbie Question - 06/08/04 20:36


I take it that it isn't possible to stop the rotation then. I'll just do away with the launcher and keep applying the force directly.
Posted By: A.Russell

Re: Newbie Question - 06/11/04 17:42


I'm getting back to making the spinners. I'm finding this very difficult, and don't really know how to approach it.

The spinners are not motorised, they should simply spin when balls hit them.

Here is a picture of the entity for the spinners:


Posted By: A.Russell

Re: Newbie Question - 06/12/04 13:13


I attempted to make the spinner from a hinge. It doesn't move at all. I assigned the spinner entities this action:

Code:
action init_spinner

{
var constraint2;

phent_settype(my, ph_rigid, ph_poly); //ph_poly -polygonal collision?
constraint2=phcon_add(ph_hinge, my, 0); //a hinge would be all that is needed in case, right?

phent_setmass(my, 0.5, ph_poly); //lighter than a ball
phent_setfriction(my, 10); //not much friction

phcon_setparams1(constraint2, my.x,vector(0,0,1),nullvector); //anchor point (origin is in centre of entity)
phcon_setparams2(constraint2, vector(360,-360,0),nullvector,nullvector); //can spin all the way around

while(my!=null) //didn't know if a loop was neccessary, so threw it in just in case
{
wait(1);
}

}



I've commented what I thought I was doing.

EDIT> Nevermind, fixed it. Amazing what a lunch break can do.


Posted By: A.Russell

Re: Newbie Question - 06/13/04 20:59


The spinners sometimes get knocked over by the balls if they are moving fast enough, like the ball launcher was. So, I'll try my luck again. Is there any way to stop this?
Posted By: A.Russell

Re: Newbie Question - 07/22/04 23:42



Just to make certain. Does the physics system only work with the new collision system (collisions with models polygons rather than collision hull)?
Posted By: A.Russell

Re: Newbie Question - 07/24/04 20:04



Well, I decided the answer should be yes.

So, I tried it out by making another level just using the model instead of the level geometry. I set the model's polygon flag on and ran it.

The balls don't move at all.

Why not?


© 2024 lite-C Forums