Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / how do i move an object in a circle motion

Author
Message
bigbrother 2000
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 6th Dec 2003 12:58
hi all,
a little stuck on this one,
how do you get a 3D object to move in a circle, by this i don't mean just rotating the object but moving the whole object around.
anybody got any ideas?
thanks
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Dec 2003 14:18
Just update the angle value to loop. To reverse rotation direction, either subtract instead of add a value to the angle, or just switch the 2 variables.

Rotate on X-axis:
Y = cos(angle) * radius
Z = sin(angle) * radius

Rotate on Y-axis:
X = cos(angle) * radius
Z = sin(angle) * radius

Rotate on Z-axis:
X = cos(angle) * radius
Y = sin(angle) * radius
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 6th Dec 2003 18:12
or you could do this:
yrotate object 1, wrapvalue(object angle y(1)+1)
move object 1,3

where 3 is the speed, and 1 is the object's number. Change the object angle y(1)+1 to object angle y(1)-1 to rotate the other way.

Morfy's Law - Enythink thet ken go rong willll.
Cole's Law - Thinly sliced cabbage.
Easily Confused
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 6th Dec 2003 18:22
A couple of orbiting examples here:
http://www.thegamecreators.com/?m=forum_view&t=11522&b=7

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
bigbrother 2000
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 7th Dec 2003 00:27
hi all

i tried TKF15H's mathod which worked well, thanks,
tho just wondered if it was possible to increase the area in which to object circles,

thanks everyone
Slayer
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: CA
Posted: 7th Dec 2003 00:57
object angle y(1)+0.3
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 7th Dec 2003 02:26
Actually, I would suggest using trigonometry, like Phaleax explains. It is quite simple, and very controllable.

Xander - Bolt Software

Why do the antagonists always have to look so cool?
Clarks
20
Years of Service
User Offline
Joined: 30th Oct 2003
Location: BALTIMORE,MARYLAND
Posted: 7th Dec 2003 03:43
You'll are just making stuff difficult. Just use Darkbasic's newvalue functions. Newxvalue, newyvalue, and newzvalue.
returnvalue=newxvalue(currentvalue,angle,stepvalue)
currentvalue is current object position
angle value is angle at which object is positioned
stepvalue acts as the radius
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Dec 2003 15:23
Where's the difficulty at?
Radius is the distance from the center of the object that you're satellite is orbiting.





Or, to have your satellite object (the orbiting one) follow the planet if it moves, just offset the values.

Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 7th Dec 2003 21:38
Yeah, c'mon guys, listen to Phaelax.

Using raw math (trig functions, etc...) is much faster than using Dark Basic's built in math functions.

Xander - Bolt Software

Why do the antagonists always have to look so cool?
Clarks
20
Years of Service
User Offline
Joined: 30th Oct 2003
Location: BALTIMORE,MARYLAND
Posted: 8th Dec 2003 04:07
Ok Phaelax i got a question

Is using the raw math functions more faster than DB built in math functions.

If so are they more effective and if so then want to ask a next question.

Can you write a piece of code that includes 2 objects. When object 1
is rotated on x,y, or z angle, object 2 moves relative to his rotation. And when i say relative i mean exact location and not a object jumping from on spot to another.

Object 1 can rotate on all angles. If object 1 yrotates object 2 position is always relative. Same thing will happen if object 1 xrotates and zrotates. Also if object 1 x,y,z position changes then object 2 position changes also and relative.

write a piece of code just to see the simplicity.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Dec 2003 08:45
In my second snippet, you can move object 1 to wherever you want and object shall follow, because of the offset values. If you want to use newxvalue() and such instead, thats fine. I doubt you'll notice the speed difference. So for the first snippet:
X = newxvalue(ax, angle, radius)
Y = newyvalue(ay, angle, radius)

Where AX and AY are the coordinates of object 1. As you can see, it's the same basic thing.

So you want an object to keep the same rotation as another? You may want to look into limbs for that.
bigbrother 2000
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 8th Dec 2003 11:32
looks like there's some brainy people here, maybe you might be able to help with my next question,

how do you get an object to fire a bullet (lets say another object sphere) at the player, so if the player gets too close to the object it will fire the sphere at the player?
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 8th Dec 2003 21:46
like this?


Morfy's Law - Enythink thet ken go rong willll.
Cole's Law - Thinly sliced cabbage.
bigbrother 2000
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 11th Dec 2003 17:59
thanks TKF15H, i've got the bullets firing from the position of the object if the player gets too close, although have i worked out the distance correctly?

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Dec 2003 22:59
remove the abs() methods. You can never get a negative number by squaring it. x*x = positive -x*-x = positive
But yes, that's correct.
bigbrother 2000
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 12th Dec 2003 23:36
hi all,

i got my object circling perfectly using this code



although now i've got a new object, i need to change the xposition on it for it to look right, (ufo which loaded horizontally which is now vertical and looks better) although now the rotating command does not work properly.

this is what has been added to put the object in the correct position xrotate object 13,270 which is entered at the top of the code so it is not in the loop,

is there any way i can get the model to continue circling as if it was moving around the edge of a cd disc, even tho i have rotated it by its xangle?
bigbrother 2000
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 13th Dec 2003 00:14
update - i took out the move object command and that stopped the object from moving vertically, which just leaves the object spinning round, but not in a circular motion such as round the edge of a cd disc, so i don't know why it has changed
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 13th Dec 2003 13:49
if your problem is the one I think you're having, after the xrotate object 13,270 put "fix object pivot 13"

Morfy's Law - Enythink thet ken go rong willll.
Cole's Law - Thinly sliced cabbage.
bigbrother 2000
20
Years of Service
User Offline
Joined: 15th Oct 2003
Location: UK
Posted: 13th Dec 2003 23:53
that worked a treat thanks, cause i had to change the xrotate the model moved in a strange way but reseting the object with the fix object pivot made it work properly.

i bought darkmatter 2 and the models are bigger than i expected, so compared to scaling the objects up i tried scale object, no., with negative numbers, however when the game starts the model is there smaller, but within 5 seconds it completly disappears, although is fine again when you take out the scale object command.

Login to post a reply

Server time is: 2024-09-21 11:52:52
Your offset time is: 2024-09-21 11:52:52