2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
pXent_settype
#451374
05/05/15 02:18
05/05/15 02:18
|
Joined: Apr 2015
Posts: 9 Ontario, Canada
kornstar
OP
Newbie
|
OP
Newbie
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
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 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: txesmi]
#451384
05/05/15 08:16
05/05/15 08:16
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
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 ). 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) Edit2: as an example, try this demo (to understand what I've meant):
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
|
|
|
Re: pXent_settype
[Re: alibaba]
#451386
05/05/15 08:40
05/05/15 08:40
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
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
|
|
|
Re: pXent_settype
[Re: 3run]
#451395
05/05/15 15:31
05/05/15 15:31
|
Joined: Apr 2015
Posts: 9 Ontario, Canada
kornstar
OP
Newbie
|
OP
Newbie
Joined: Apr 2015
Posts: 9
Ontario, Canada
|
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 ). 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: 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
|
|
|
Re: pXent_settype
[Re: DLively]
#451405
05/05/15 17:11
05/05/15 17:11
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Just to clarify, I think that what you meant by: 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. 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 Thank you scorekeeper Best regards!
|
|
|
Re: pXent_settype
[Re: DLively]
#451409
05/05/15 17:56
05/05/15 17:56
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Thank you scorekeeper 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 Best regards
|
|
|
|