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.

DarkBASIC Discussion / Point at an object gradually?

Author
Message
MoonSon
22
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 6th Jan 2004 15:04
Im using the 'point at' command with 'curveangle' command to create gradual rotation to its target. The problem is, curveangle makes the object slow down as it reaches its target. Instead I need a consistant speed of rotation as it points towards its target, but it also needs to know the quickest direction.

Anyone know how this can be done? Is there another command im missing?
Robin
22
Years of Service
User Offline
Joined: 22nd Feb 2003
Location: United Kingdom
Posted: 6th Jan 2004 15:50 Edited at: 6th Jan 2004 15:51
You could point the object at the target object, get the rotation values of the object now, and then return the object to the original rotation. Then increasing the rotation of the object by a constant value until it matches the rotation when the object was pointing at the target object, should work. (what a mouthfull lol ). You'd need to work out the quickest way to get to the new rotation values somehow. i'll work out something tonight if no-one else has by then
hope i helped
Robin

http://www.thegameszone.tk | [email protected]
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Jan 2004 18:15
To answer the question, there is no command to do this, you need to program it manually.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 6th Jan 2004 20:29
It's very hard to make it turn the right direction, but what Robin says is right - I think that's the only way.

MoonSon
22
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 7th Jan 2004 12:35
Thanks for the help!

There must be a way to manipulate curveangle so it doesnt slow down. It would be great if i could still use it some way, as it solves the right direction problem.

I was thinking maybe giving the curveangle speed value a variable and then change the speed depending how close it is to its target?!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 7th Jan 2004 13:58
look for the atanfull and tan commands
MoonSon
22
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 7th Jan 2004 15:11
atanfull is for 2D stuff and god knows what this means:

TAN()
This command will return the tangent of the value.

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jan 2004 23:35 Edited at: 7th Jan 2004 23:36
Quickest Direction - Get the curveangle() between the 2 objects. If it's less than 180 degrees, go with it. If it's greater than 180 degrees, subtract it from 360 and reverse the sign.

Constant rotation velocity - Depends on whether either of the objects are moving. If they are, you need to recalculate every time you move. Even so, you could divide the angle by the number of frames you wish to reach the destination by. After each rotation, check if the next rotation will take you past where you want to be. If it does, you'll have to compensate on the last frame.

If the objects are moving, you will never know exactly how long it will take you to reach the target, unless you alter the angle of each rotation depending on where the objects currently lie in relation to each other. So you need to decide if constant rotation, or the time it takes to reach the object is most critical.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 8th Jan 2004 02:28 Edited at: 8th Jan 2004 03:05
This should do, thanks DarthSter for slapping math sense back into me



RPGamer


We need help! Email us! [email protected]
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 8th Jan 2004 02:30
PS - Moonson, you will learn SINE, COSINE and TANGENT in probably Algebra 2 in school


We need help! Email us! [email protected]
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 8th Jan 2004 03:02
We just did a little in Algebra 1


John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 8th Jan 2004 03:04
There ya go

If you wanted to use the point object way, it might be best to use a hidden dummy object as well.

Id put a cube where the player is, and have it follow all the same movements only be hidden. That way, if you wanted to point the player to something, you could first point the cube to that object and then increment the players Y angle until it is the same as the cubes Y angle

RPGamer


We need help! Email us! [email protected]
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 8th Jan 2004 03:43
i didn't learn anything in my albera unit, my school is retarted

I am mischeivious
RoooooOoooooKoooooKoooooRoooooOoooooKoooooKooooo!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 8th Jan 2004 05:59
lol , so did the problem get solved?
MoonSon
22
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 8th Jan 2004 19:36
Ive been through school and it taught me nothing! Im using Dark Basic so i dont have to be Einstein to program.

RPGamer does that all work for a 3d environment though?

Thanks for all your help, when my brain is switched on i will try to work all this out.
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 8th Jan 2004 22:11
MoonSon - Seeing as I use OBJECT POSITION, yes it should If the code is a bit off, it should give you a good idea at least

RPGamer


We need help! Email us! [email protected]
Sjakie
21
Years of Service
User Offline
Joined: 17th Dec 2003
Location: Netherlands - Delft
Posted: 14th Jan 2004 23:08
The AtanFull() command is holy when doing this because the point command in Darkbasic Classic is not pretty stable... i've build as a test a cannon that aims at an flying object but sometimes the cannon flipped over and became insane... i think you need to write your own Point function... btw the Atanfull command is just giving the x distance and y distance between 2 points and PLOP there's the angle in degrees

Juzt a dude who likez progging

Login to post a reply

Server time is: 2025-05-22 06:13:50
Your offset time is: 2025-05-22 06:13:50