Gamestudio Links
Zorro Links
Newest Posts
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
FXCM => AVA Trade Plugin???
by Martin_HH. 11/17/26 17:02
contractUpdate() is filtering if >2 rows
by mistery. 11/09/26 12:06
New Zorro version 3.15
by jcl. 11/09/26 09:24
Removing outliers from files
by jcl. 11/04/26 10:30
[MED] Import from FBX (2010) missing!!!
by rayp. 11/03/26 14:33
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (Grant, EvanTJ, LucasJoshua, EW_bytes, 1 invisible), 35,701 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Rotate while Moving #180039
01/26/08 17:16
01/26/08 17:16
Joined: Jan 2008
Posts: 13
Everywhere
ajsquared Offline OP
Newbie
ajsquared  Offline OP
Newbie

Joined: Jan 2008
Posts: 13
Everywhere
I am working on a game that involves the player moving a ball through a maze, and I would like to make the ball roll while it moves. How would I do this?

I've tried using using c_rotate and ang_add, but these just seem to change the direction the ball is facing.

Last edited by ajsquared; 01/27/08 16:02.
Re: Rotate while Moving [Re: ajsquared] #180040
01/27/08 21:46
01/27/08 21:46
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
You need to use the physics engine to do this:

Code:

float thrustX,thrustY;

...

void phys_ent()
{
ENTITY* pent= me;
phent_settype(me,PH_RIGID,PH_SPHERE);
phent_setmass(me,2,PH_SPHERE);
phent_setfriction(me,60);
phent_setelasticity(me,30,20);
phent_setdamping(me,40,30);
while(pent)
{
phent_addcentralforce(me,vector((thrustY * 1000) * (key_cur - key_cul),(-thrustX * 1000) * (key_cur - key_cul),0));
phent_addcentralforce(me,vector((thrustX * 1000) * (key_cuu - key_cud),(thrustY * 1000) * (key_cuu - key_cud),0));
thrustX= cos(-camera.pan);
thrustY= sin(camera.pan);
vec_set(temp,pent.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp);
wait(1);
}
}



This should allow you to control a ball physics entity with the arrow keys. The direction is always relative to the view (meaning forward is always away from the camera, backward is always towards the camera, etc.).

You may need to change a few things, like changing the "void" to "action" (if you want to attach it o an entity in WED), and changing the variable declaration if you're using C-Script (from "float thrustX,thrustY;" to "var thrustX; var thrustY;").


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Rotate while Moving [Re: MrCode] #180041
01/27/08 23:37
01/27/08 23:37
Joined: Jan 2008
Posts: 13
Everywhere
ajsquared Offline OP
Newbie
ajsquared  Offline OP
Newbie

Joined: Jan 2008
Posts: 13
Everywhere
Thanks! This is exactly what I'm looking for.


If the facts don't fit the theory, change the facts.

Moderated by  HeelX, Spirit 

Gamestudio download | 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