Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
pXent_settype #451374
05/05/15 02:18
05/05/15 02:18
Joined: Apr 2015
Posts: 9
Ontario, Canada
K
kornstar Offline OP
Newbie
kornstar  Offline OP
Newbie
K

Joined: Apr 2015
Posts: 9
Ontario, Canada
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.

Last edited by kornstar; 05/05/15 03:15.
Re: pXent_settype [Re: kornstar] #451380
05/05/15 07:16
05/05/15 07:16
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
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!

Re: pXent_settype [Re: txesmi] #451384
05/05/15 08:16
05/05/15 08:16
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
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

Last edited by 3run; 05/05/15 09:42. Reason: added code

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: pXent_settype [Re: 3run] #451385
05/05/15 08:36
05/05/15 08:36
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
I think setting the table as PH_CHAR and rotating it with pXent_rotate should also work. Just try it!


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: pXent_settype [Re: alibaba] #451386
05/05/15 08:40
05/05/15 08:40
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
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


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: pXent_settype [Re: 3run] #451395
05/05/15 15:31
05/05/15 15:31
Joined: Apr 2015
Posts: 9
Ontario, Canada
K
kornstar Offline OP
Newbie
kornstar  Offline OP
Newbie
K

Joined: Apr 2015
Posts: 9
Ontario, Canada
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

Re: pXent_settype [Re: kornstar] #451398
05/05/15 15:59
05/05/15 15:59
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
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


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: pXent_settype [Re: DLively] #451405
05/05/15 17:11
05/05/15 17:11
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
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!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: pXent_settype [Re: 3run] #451408
05/05/15 17:43
05/05/15 17:43
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Quote:
Thank you scorekeeper

What do you mean?


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: pXent_settype [Re: DLively] #451409
05/05/15 17:56
05/05/15 17:56
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
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


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1