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 Professional Discussion / Third person aiming with new(xyz)value??

Author
Message
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 14th May 2011 19:03
I am having a bit trouble making a precise aim system with the newxvalue, newyvalue and newxvalue, my code is like this

(object 100 is player, object 50 is a plain with crosshair texture)



I subtract 1 from y value to make it a bit more precise :-P

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 14th May 2011 23:50 Edited at: 15th May 2011 13:43
The newxyzvalue() commands are quite deceiving. They stand for:

newxvalue(x#, a#, r#) = x# + sin(a#)*r#
newyvalue(y#, a#, r#) = y# - sin(a#)*r#
newzvalue(z#, a#, r#) = z# + cos(a#)*r#

The reason that newyvalue() is defined like that is probably for using it in 2D (because the Y-axis points downwards, hence -sin()).
[edit] The newxyzvalue() commands can also be used to rotate around a point along the XY or XZ plane. Eg. a point on a circle in the XY-plain can be written as:
x# = 0
y# = newyvalue(0, ax#, r#)
z# = newzvalue(0, ax#, r#)
And that's why newyvalue() is defined like that. The minus in newyvalue() is to make the rotation follow the left-hand rule.

To find the point you're searching for, you can use:
x# = newxvalue(cx#, ay#, cos(ax#)*r#)
y# = y# + sin(ax#)
z# = newzvalue(cz#, ay#, cos(ax#)*r#)

Only works if the Z-rotation is 0.

Cheers!
Sven B

Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 15th May 2011 00:23
Thank you Sven B, I will look at it soon

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 15th May 2011 00:27
I haven't really found any cases where i could use NewYvalue for anything... the X and Z are the only useful for me.

-In.Dev.X: A unique heavy story based shoot'em ~25%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 15th May 2011 14:23
y# = y# + sin(ax#) won't raise my camera or crosshair on the Y axis?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 15th May 2011 14:27
There's a use for newyvalue.
It is not very precise tho, probably my fault
see example
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 15th May 2011 14:37
By the way, what should r# be? Variable range?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 15th May 2011 14:41
r# is the radius of the circle along which the point will move
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 15th May 2011 14:42
When X axis in my player rotates it moves the crosshair back and forth :S



The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 15th May 2011 17:16
Because the newxvalue/newzvalue function (or trig for the matter) work on the horizontal flat plane projection.
Whenever you change the x angle the x projection gets shorter or longer.
this is putting the distance calculation totally off at an angle.
You will be better off by attaching a limb to your player at crosshair position, hide it and position the crosshair at hidden limb's position
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 15th May 2011 18:39
Okay, that sounds like a plan Scorpyo, I will try that

Do you think the same should be done for the camera? I found that the first system I used worked quite well for the camera, but not crosshair, I better try both, just to see which one I like better for camera

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...

Login to post a reply

Server time is: 2026-07-10 19:49:22
Your offset time is: 2026-07-10 19:49:22