pXent_settype

Posted By: kornstar

pXent_settype - 05/05/15 02:18

Hi,

I'm trying to create a small game that uses physics to move a ball around on a small flat table by tilting the table, I have successfully added physics to the ball (as far as I know) from the example in the workshops but I'm having a hard time setting up the table.

I first tried to simply set the table to tilt/roll using mouse_force.x and mouse_force.y and was able to get the table to move as I wanted it to but without adding the 'pXent_settype' I found that the ball would go right through the table.

I then tried to add physics to the table using PH_BOX, but the table is then subject to gravity (just like the ball) and falls out of sight.

My latest attempt was to set the table to
Code:
pXent_settype(me, PH_RIGID, PH_PLANE);



and the table stays where I put it but now the movement of the mouse no longer affects the tilt/roll of the table.

does anyone know if/how I can set-up the physics on the table so that the ball will not go through the table but still be able to make the table tilt/roll with the movement of the mouse and not have it fall with gravity?

any and all help with this is appreciated laugh

edit: I recently found the includes folder and opened ackphysX.h and am reading through it to try to figure this out, but still any help from experienced users is appreciated.
Posted By: txesmi

Re: pXent_settype - 05/05/15 07:16

Hi,
the physic objects angles are managed by the physics engine. You can not set the angles directly. You need to rotate them by applying forces. I think 'pXent_setangvelocity' is the best for your needs, but you can also control the table by applying torque (pXent_addtorque...) or uncentered linear forces (pXent_addforce...).

The table have to hang from the world by a joint (pXcon_add) in order to avoid falling to the infinite. PH_BALL joint is the simplest but it does not have rotating limits. You may set up a double PH_HINGE.

Salud!
Posted By: 3run

Re: pXent_settype - 05/05/15 08:16

Hi!

I think you are trying to create something similar to Labyrinth game on mobile devices (you won't be able to see the rolling of the table on the video, cause iphone is actually the table grin ). I've made one pretty long time ago, and I didn't roll the table at all! Think about it in a different way! Don't roll the table, but change camera angles instead! For the end user is doesn't really matter since it looks like table is rolling and ball is moving correctly.

Edit: I finally found this old thread (it's from 2011) grin

Edit2: as an example, try this demo (to understand what I've meant):
Code:
void main(){
	fps_max = 60;
	
	level_load("");
	wait(3);
	
	ENTITY* planeEnt = ent_create(CUBE_MDL, nullvector, NULL);
	vec_set(planeEnt.scale_x, vector(10, 10, 0.5));
	wait(1);
	c_setminmax(planeEnt);

	var i = 0;
	
	ENTITY* testEnt[4];
	
	for(i = 0; i < 4; i++){
		testEnt[i] = ent_create(CUBE_MDL, nullvector, NULL);
		vec_set(testEnt[i].scale_x, vector(10, 1, 1));
		wait(1);
		c_setminmax(testEnt[i]);
	}
	
	vec_set(testEnt[0].x, vector(0, planeEnt.max_y - testEnt[0].max_y, testEnt[0].max_z - (testEnt[0].min_z / 2)));
	vec_set(testEnt[1].x, vector(0, planeEnt.min_y + testEnt[1].max_y, testEnt[1].max_z - (testEnt[1].min_z / 2)));
	vec_set(testEnt[2].x, vector(planeEnt.max_x - testEnt[2].max_y, 0, testEnt[2].max_z - (testEnt[2].min_z / 2)));
	vec_set(testEnt[3].x, vector(planeEnt.min_x + testEnt[3].max_y, 0, testEnt[3].max_z - (testEnt[3].min_z / 2)));
	
	testEnt[2].pan += 90;
	testEnt[3].pan += 90;
	
	var cam_pan = 0, cam_tilt = -90;
	
	camera.arc = 90;
	
	while(1){

		cam_pan -= 0.05 * mickey.x;
		cam_pan = clamp(cam_pan, -5, 5);

		cam_tilt -= 0.05 * mickey.y;
		cam_tilt = clamp(cam_tilt, -95, -85);
		
		vec_set(camera.pan, vector(0, cam_tilt, 0));
		ang_rotate(camera.pan, vector(cam_pan, 0, 0));
		
		vec_set(camera.x, vector(-(cam_tilt + 90) * 2, -(cam_pan) * 2, 150));
		
		wait(1);
	}
}



Greets
Posted By: alibaba

Re: pXent_settype - 05/05/15 08:36

I think setting the table as PH_CHAR and rotating it with pXent_rotate should also work. Just try it!
Posted By: 3run

Re: pXent_settype - 05/05/15 08:40

Originally Posted By: alibaba
I think setting the table as PH_CHAR and rotating it with pXent_rotate should also work. Just try it!
Unfortunately it won't, cause CHAR can have only BOX and CAPSULE shape (maybe convex works too, but it has it's limits too).

Greets
Posted By: kornstar

Re: pXent_settype - 05/05/15 15:31

Originally Posted By: 3run
I think you are trying to create something similar to Labyrinth game on mobile devices (you won't be able to see the rolling of the table on the video, cause iphone is actually the table grin ). I've made one pretty long time ago, and I didn't roll the table at all! Think about it in a different way! Don't roll the table, but change camera angles instead! For the end user is doesn't really matter since it looks like table is rolling and ball is moving correctly.


You are correct, the old school labyrinth "board" game is exactly what I was thinking about, It seemed to be a fairly simple idea to create, I'm now figuring out that there will be a lot more to it than I had originally anticipated (as is the case with almost any idea I have), but I'm going to stick with it for learning purposes.

Just to clarify, I think that what you meant by:

Originally Posted By: 3run
Think about it in a different way! Don't roll the table, but change camera angles instead!


is to keep the table flat, apply the forces to the ball instead and have the camera tilt to create the illusion that the table is tilting. Is that what you meant?

@ txesmi, 3run, and alibaba: thank you all for taking the time to help me, I very much appreciate it and I will look through and try your suggestions sometime today.

Thanks again laugh
Posted By: DLively

Re: pXent_settype - 05/05/15 15:59

Quote:
is to keep the table flat, apply the forces to the ball instead and have the camera tilt to create the illusion that the table is tilting. Is that what you meant?


Yes that is exactly what was suggested laugh
Posted By: 3run

Re: pXent_settype - 05/05/15 17:11

Originally Posted By: kornstar
Just to clarify, I think that what you meant by:

Originally Posted By: 3run
Think about it in a different way! Don't roll the table, but change camera angles instead!


is to keep the table flat, apply the forces to the ball instead and have the camera tilt to create the illusion that the table is tilting. Is that what you meant?
Yes, that's exactly what I've meant. Don't rotate the table, but rotate and move camera (in the opposite direction of the rotation)! Create 'illusion' of rotating table. I'm pretty sure none of those games actually really rotating the table, it's more likely to be a static object, for performance and stable simulation issues.

To make things even more clear, just run the code I'm posted above, it already has camera movement part, so you can start with it as a base. You can also use those two variables (which are used to rotate and move camera) to apply forces to the ball (in the opposite direction of the rotation I guess), so it will really looks like table is rotating, and ball is sliding down.


Originally Posted By: DLively
Quote:
is to keep the table flat, apply the forces to the ball instead and have the camera tilt to create the illusion that the table is tilting. Is that what you meant?

Yes that is exactly what was suggested laugh
Thank you scorekeeper tongue


Best regards!
Posted By: DLively

Re: pXent_settype - 05/05/15 17:43

Quote:
Thank you scorekeeper

What do you mean?
Posted By: 3run

Re: pXent_settype - 05/05/15 17:56

Originally Posted By: DLively
Quote:
Thank you scorekeeper tongue

What do you mean?
That means that I don't need anyone to confirm my words and speak for me.
Keep that in mind in order to avoid misunderstandings in future laugh

Best regards
Posted By: DLively

Re: pXent_settype - 05/05/15 18:06

Thanks, But I can say what I want, when I want. Keep that in mind in order to avoid misunderstandings in the future.
Posted By: Anonymous

Re: pXent_settype - 05/05/15 18:08

Lol love these combative posts. But to help the newbies can we port them over to a Rants? It floods the thread otherwise.

Just asking,
Mal
Posted By: 3run

Re: pXent_settype - 05/05/15 18:16

Originally Posted By: DLively
Thanks, But I can say what I want, when I want. Keep that in mind in order to avoid misunderstandings in the future.
Man, say whatever you want, but don't speak for me, ok? grin As I've said, if I'll need scorekeeper, I'll let you know.

Originally Posted By: Malice
Lol love these combative posts. But to help the newbies can we port them over to a Rants? It floods the thread otherwise.

Just asking,
Mal
You are actually right. My bad.

kornstar@ sorry for offtopic man.

Best regards
Posted By: DLively

Re: pXent_settype - 05/05/15 18:22

I didn't speak for you. I spoke for myself. Infact, I AGREED with what you said, so stop being so uptight. Your not the Admin, or mod. Just a user. Stop trying be something your not - the boss. I'll do and say what I want when I want and agree with or disagree with whomever I'd like. In other words: (I don't need your permission to post on this forum)
Posted By: 3run

Re: pXent_settype - 05/05/15 18:23

Originally Posted By: DLively
I didn't speak for you. I spoke for myself. Infact, I AGREED with what you said, so stop being so uptight. Your not the Admin, or mod. Just a user. Stop trying be something your not - the boss. I'll do and say what I want when I want and agree with or disagree with whomever I'd like. In other words: (I don't need your permission to post on this forum)
stop offtopic and check your PM!
Posted By: DLively

Re: pXent_settype - 05/05/15 18:27

You totaly, needlessly went off topic, and continue to do so. If you want to boss people around, or be a bully -- Im sure others would advise you to go to your own forum.

I simply told kornstar that the information you provided was correct (staying on topic) Your attempts to be be-little me brought it off topic.
Posted By: kornstar

Re: pXent_settype - 05/05/15 18:31

As far as I'm concerned the information I needed is all on the first page and if I have any other questions I will post them in a new thread specific to the question so feel free to duke it out all you like tongue
Posted By: Anonymous

Re: pXent_settype - 05/05/15 18:42

Quote:
and if I have any other questions I will post them in a new thread specific to the question


My point.
Posted By: 3run

Re: pXent_settype - 05/05/15 19:12

Originally Posted By: kornstar
As far as I'm concerned the information I needed is all on the first page and if I have any other questions I will post them in a new thread specific to the question so feel free to duke it out all you like tongue
Usually we all leave in peace and harmony, don't think that forum is fulfilled with evil persons like me grin

Edit:

I just noticed that kornstar is from Canada too. Maybe you guys even know each other (DLively and kornstar), that makes sense actually. I would probably act the same (trying to help) if I would see someone from Russia over the forum. So I probably overreacted on what DLively wrote, and I'm sorry for that.
Posted By: kornstar

Re: pXent_settype - 05/06/15 02:14

Originally Posted By: 3run
I just noticed that kornstar is from Canada too. Maybe you guys even know each other (DLively and kornstar), that makes sense actually. I would probably act the same (trying to help) if I would see someone from Russia over the forum. So I probably overreacted on what DLively wrote, and I'm sorry for that.


At first I wasn't even sure if I wanted to answer that because I don't want any blow over because of it but yes DLively and I do know each other, in fact we are related, I am his older cousin. It was DLively who got me interested in 3dgs in the first place, and much of what I know already was learned from him.

He used to help me with advice over the phone but our schedules don't always match up so I decided to start looking for help on the forum, I also figured that on the forum I would have access to the wide well of knowledge offered by the many helpful forum users and in the end the more input I can get...the more I will learn... and ultimately the better off I would be.

OH and don't worry about the "battle" posts, I have used many forums in the past and one thing that I learned is that when this many people get together in one place, people tend to butt heads from time to time (I'm not calling you Buttheads...well maybe DLively...lol tongue ) so I have not formed any bad impressions about this forum because of a couple little squabbles. I know from DLively that this is a great community and I look forward to getting to know you all regardless of what disagreements you have among each other.

So to end this all off I will say Thank you one more time to you all for the help with my question, and I'm sure I will have more questions for you all in the near future. grin
© 2024 lite-C Forums