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.

Dark GDK / Step Towards Object?

Author
Message
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 4th Oct 2008 22:40
I'm trying to get one object to step towards another object regardless of x,y,z locations.

I've checked the help files and this is what I got:

Quote: "dbMoveObject
This command will move the specified 3D object in 3D space. The command uses the current direction of the object and moves it using the specified step value.

Syntax
void dbMoveObject ( int iObject, float fSpeed ) "


Quote: "dbMoveObjectDown
This command will move the object in a down direction relative to its forward facing angle, rather than an absolute world direction.

Syntax
void dbMoveObjectDown ( int iObject, float fValue ) "

Quote: "
dbMoveObjectLeft
This command will move the object in a left direction relative to its forward facing angle, rather than an absolute world direction.

Syntax
void dbMoveObjectLeft ( int iObject, float fValue ) "


And so on....


But there is nothing that will step an object towards another object.

Is there such a function or will I have to craft something myself?
Wikaman1
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Scotland
Posted: 4th Oct 2008 22:48
yes you have to check if rotation is needed, then get the angle of rotation, the rotate and then you can move the object towards another object. This has to be in a loop so that it is always checking if rotation is needed.
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 4th Oct 2008 22:52
Quote: "yes you have to check if rotation is needed, then get the angle of rotation, the rotate and then you can move the object towards another object. This has to be in a loop so that it is always checking if rotation is needed. "


I'm a little confused on that... Could you explain a little more please?
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 4th Oct 2008 23:59
You could use dbPointObject to point it to another object location and then call dbMoveObject to move towards it!

[center][center]
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 5th Oct 2008 00:25 Edited at: 5th Oct 2008 00:40
Quote: "You could use dbPointObject to point it to another object location and then call dbMoveObject to move towards it!"


Brilliant!

Why did I not think of that...



Edit:
The movement of the object doesnt look right... They only move sideways and at somepoints, they dont move at all.
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 5th Oct 2008 00:38
Yay! I glad you decided to stay Rei Kumar! I have another solution to this if you are looking for an actual sliding effect. Kinda like AI way points.

Let me know if you want me to post it here. It would be lengthy and I don't wanna spend the time to do it if you don't need it haha.

P.S. Much better posting format! Lol.

www.Helios-Online.net
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 5th Oct 2008 00:41
Quote: "Yay! I glad you decided to stay Rei Kumar! I have another solution to this if you are looking for an actual sliding effect. Kinda like AI way points.

Let me know if you want me to post it here. It would be lengthy and I don't wanna spend the time to do it if you don't need it haha.

P.S. Much better posting format! Lol.
"


What can I say, I'm a slow learner. But thanks. what is this AI waypoints you speak of?
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 5th Oct 2008 00:58
I thought you wanted the object to "slide" to the other. You would have to include a collision lib.

www.Helios-Online.net
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 5th Oct 2008 01:02
I want one object to travel towards another.

Object B wants to be at Objects A's position at all times and will travel in that direction, no matter where Object A goes.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 5th Oct 2008 01:34
dbPointObject(Object_A, Object_B);
dbMoveObject(Object_A, Object_As_Speed);
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 5th Oct 2008 01:34
Well my question was, how do you want it to do that? Like do you want it to slowly slide to the other object, or just automatically appear in the other objects location.

But if kBessa's snippet did what you wanted it to do, then void what I'm saying haha. I tend to want to over do things. :3

www.Helios-Online.net
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 5th Oct 2008 02:01
Quote: "dbPointObject(Object_A, Object_B);
dbMoveObject(Object_A, Object_As_Speed); "


That doesn't work correctly because they only seem to move sideways.


Quote: "Well my question was, how do you want it to do that? Like do you want it to slowly slide to the other object, or just automatically appear in the other objects location.

But if kBessa's snippet did what you wanted it to do, then void what I'm saying haha. I tend to want to over do things. :3"


I want it to step to the location.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 5th Oct 2008 21:40
Quote: "That doesn't work correctly because they only seem to move sideways."


It won't turn the model for you. You have to do the rotating yourself. That will simply move it through space towards it.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 5th Oct 2008 23:36
He's doing a guided missile, I think.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Oct 2008 23:53
Quote: "That doesn't work correctly because they only seem to move sideways."

Before the main loop, rotate the object so that it is facing forward, using 'rotate object', then use 'fix object pivot'
The problem is that your object was not made pointing in the right direction.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 5th Oct 2008 23:55
To answer the OP exactly, the efficient method would be to use vectors.

Pseudo code:

newPosition = curPosition + normalize( targetPosition - curPosition ) * speed

ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 6th Oct 2008 00:32
Quote: "He's doing a guided missile, I think. "


Guided Raptor actually... I want my Raptor (dinosaurs) to follow my player.

Quote: "Before the main loop, rotate the object so that it is facing forward, using 'rotate object', then use 'fix object pivot'
The problem is that your object was not made pointing in the right direction."


I already did. The problem is that it wont move towards me on the Z axis.



Quote: "newPosition = curPosition + normalize( targetPosition - curPosition ) * speed"


Mind explaining that a little more please?
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 6th Oct 2008 12:57
ReiKumar

For every loop you need to calculate a new position for your raptor.

Niels Henriksen
www.tales-of-the-realms.com
if Microsoft can sell software with bugs, so can I.

Login to post a reply

Server time is: 2024-11-25 03:48:09
Your offset time is: 2024-11-25 03:48:09