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 / Offset an object

Author
Message
MoonSon
21
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 25th Feb 2003 13:06
Ive been trying to offset my bullets so they fire above my camera. Problem is when i roll the camera the bullets do not roll with it. Ive tried the NEWVALUE commands but having no luck.

Anyone know how to offset an object from a moving parent?

thanks
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 25th Feb 2003 14:10
Id suggest just positioning the camera and bullets using the same X value. First, Id use a cube as a dummy object, and use that to move the camera, for It seems you are making a FPS.

So, code your movement for the cube, then positioned the camera at all the object coodinates like

x#=object position x(1)
y#=object position y(1)
z#=object position z(1)

Position camera x#,y#,z#+10

Then when you position your bullets, positioned them at nessecary y and z coodinates (z matters most) then just position the object at the same x coordinate as the camera (or dummy object)

postion object(my bullet) x#,y#,use an increasing z coord

I hope this helps you!

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
MoonSon
21
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 25th Feb 2003 14:37
thanks, yeah i think that works ok, but i think the problem lies in rolling the object (as im doing a flight sim). The bullets are offset, but when you roll, the bullets stay where they are so it could look like they are firing beneath or by the side of you.

I need the bullet object to move round with the camera as it rolls

Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 25th Feb 2003 19:49
bulletx#=sin(cameraangle#)*(+offset)
bulletz#=cos(cameraangle#)*(-offset)
position object bullet,bulletx#,height#,bulletz#

if it doesn't work invert the "offset" signs (negative to positive etc..)
I'm at work , cannot test it
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 26th Feb 2003 04:13
Ooops sorry didnt know you were rolling But yes your going to have to use math and camera angle to position the bullet now Fun fun!

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy!
MoonSon
21
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 26th Feb 2003 12:18
Thanks, I'll give that a go


One other thing is that I did read that:

NEWXVALUE(Current X Value, Angle Value, Step Value) etc,

is supposed to replace the need for COS and SIN maths. So I had a go but couldnt get the results. Is it simply that these commands are no good when rolling an object?

Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 27th Feb 2003 00:53
Basically, it mimics the sin/cos effect, but , in your example above the step will offset the position straight behind the object or camera if step value is negative , or straight before if step value is positive, because it re-adjusts the alignment to the angle value.
meanwhile my sin/cos example code offsets laterally .
to achieve the same you must add an offset to the angle value too..like:
newxvalue=(current x value, angle value + angle offset,step value)
make sure you use wrapvalue(angle value+offset) or you'll get an angle value overflow
give it a try and let me know..
cheers
MoonSon
21
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 7th Mar 2003 12:57
Ive tried out these methods and i still cant get it to work, im a bit confused.

This is the code I've got:



I want to avoid maths if i can, so ive used NEWVALUE commands.

What exactly do i need to do with the code so that object 1 stays above the camera but moves around with the camera when it rolls?

Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 7th Mar 2003 23:34
well..try this code and study it... i hope it can help
or use the part that you need...
the bullet is the small sphere visible on the cube gun..
it is offsetted with sin/cos in order to stay in position when turning the cube..
use arrows to move and turn..
cheers


Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 8th Mar 2003 00:26
This may suit your needs better..

Login to post a reply

Server time is: 2024-09-19 22:29:54
Your offset time is: 2024-09-19 22:29:54