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 / 3rd person crosshair success?

Author
Message
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 30th Oct 2003 01:23
In DBClassic has anyone had any success with a 3rd person view situation where the character the player controls has a crosshair that points in the direction of that character? If so, how did you go about this, and how did you keep the crosshair within a distance where it was always visible? Questions, comments, code snippets, and suggestions are desired - thank you!

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 30th Oct 2003 03:28 Edited at: 30th Oct 2003 11:05
Ok,
I haven't perssonally done this, but the way i would go about it would be;

1) I would make the crooshairs a textured plain that is Set To Object Orientation but positioned about 100 world units infront (or whatever).

2) By simply putting in the code Set Object To Object Orientation in every loop, and positioning it away from the character every loop, the crosshair would always be directly infront of the character.

3) To stop it from going behind other objects, i would put in a verticle hiden plain at right angles to the player/crosshair that would extend from the player to the crosshair (but no further)

4) Then i would check to see if that plane is colliding with another object (ie, if an object is blocking hte visibility of the crosshairs from the character).
5) I would then get the distance from the character to the object using the distance formula:


6) Then the plain that is the crosshairs would be positioned just a bit less than that distance.

Here's a bit of code to demonstrate this:


The above code doesnt have the distance formula in it, because then i would just be giving you the code... That's a start, good luck...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 30th Oct 2003 06:24
Thanks a bunch . I am realizing that I am fighting a losing battle trying to reinvent the wheel (namely: parametric equations in a pathetic testing algorythm). I think this new approach is something that I should try...

(yes, intersect object is a DBPro command )

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 30th Oct 2003 11:04
Um, i didn't mean intersect object...

Here, i finished the code for you...



You'll notice that when the crosshairs collide with the objects, it seems to keep moving (which it shouldn't) into the object,but alot slower, mabey you can fix this problem?

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 31st Oct 2003 01:32 Edited at: 31st Oct 2003 01:49
Yes, this is really awesome. I slightly modified the code so that the entire crosshair remains visible even if the object is not ghosted.
However, what if the crosshair moves behind a raised sector of the matrix?

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 31st Oct 2003 07:38
check to see if the plane that is at right-angles to the character is intersecting the matrix, if it is, then position the cross-hair at the position of the matrix...

Hmm, can i have the code that you modified, becasue i really couldn't get around the cross-hairs sinking into the objects, it had me thinking for ages...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 31st Oct 2003 17:24
I cheated a bit by experimenting with the values in the collision code. I non-ghosted the boxes and changed only this line:



I've made out a few theories on why this works, but I'm a bit fuzzy with the collision algorythm anyways. I'm assuming that if the object was REALLY big it wouldn't work. What do you think?

I found a way to check an object distance from the matrix. As soon as I get back home, I'll show you a snippet. However, if I use that method I'd have to increment the distance of the crosshair by tiny increments until either collision with the matrix happens, or the max_distance is reached. That could be quite a waste of memory come to think of it...

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 1st Nov 2003 05:24 Edited at: 1st Nov 2003 05:39
Quote: "I'm assuming that if the object was REALLY big it wouldn't work"


No, the way you set the distance equation up, it is finding the distance to a point in space about half the width of the object in front of it.

To see what i mean, change this:


To this:


And make the cross-hairs collide with an object so you can see it side-on... You'll notice that the cross-hairs come out, far infront of the object therefore not really poisitioning it where it should be (although, it does look alright)

Hmm, for the matrix collision, you could try:


But, atm, i can't get it to work properly!!

That's the basic structure that you'll need (i think) so if you can get it working then good on ya!.

Quote: "I found a way to check an object distance from the matrix. As soon as I get back home, I'll show you a snippet. However, if I use that method I'd have to increment the distance of the crosshair by tiny increments until either collision with the matrix happens, or the max_distance is reached. That could be quite a waste of memory come to think of it..."


I'm not too sure what you mean by this, but if it's a different approach to the problem than mine, then I'll be happy to see it

[EDIT]If you set-up your floor etc as objects and planes etc, then you wouldn't have to worry about the matrix intersection etc...[/EDIT]


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 1st Nov 2003 22:19 Edited at: 1st Nov 2003 23:44
The variable for MatrixYThreshold works like this. I realized that it is actually unnecessary for the code you're working on since it isn't dealing with freeflight like in Terminal Velocity or StarWraith:



I changed the code drastically. The primary change is the matrix testing algorythm which actually works! However, it has completely botched up the object testing code for some reason. The secondary changes include y# equalling 50, and the object testing code we discussed earlier.



Let me know what you think...

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 1st Nov 2003 23:51 Edited at: 1st Nov 2003 23:53
I was playing around some more with the collision segment in the original masterpiece (before I started dinking around with matrix collision). This should prefore a much more desireable crosshair repositioning



I still can't seem to reconcile my matrix collision code in the before-hand post. Like I said, it works fine until the crosshair collides with one of the boxes...

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 2nd Nov 2003 06:33
Here ya go, change it to:


That checks to make sure that there is no object collision first, therefore it wont lock-up.

And your distance formula is wrong... Here's all of my code fixed up, it includes so that the player object is positioned at the matrix height, and it has a better distance equation. Also, i changed the distance of the cross-hairs so it looks a bit more realistic...




Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 2nd Nov 2003 21:29
That's just awesome. Basically, all of my 3rd person crosshair problems have been solved - except one: I can't seem to get just ANY distance to work. Even at most values below 300, it still moves the crosshair where it shouldn't.

I'm still working on that problem. Thanks for all your heaping help so far .

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 2nd Nov 2003 23:07
Hey, i'm just being a nice guy

So what's wrong with the distances? mabwy i can help with that also? lol...

Anyway, good team work...

Glad I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 3rd Nov 2003 03:43
I think I've got it working. I changed these two lines:



and


I'm still theorizing to exactly how my theory works (This is another one of those strange weaknesses of mine). I'm guessing that it has something to do with how the plain will react when the collision testing algorythm is accounted for. Any thoughts?

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 3rd Nov 2003 03:54
Sorry, i stil don't undestand what your problem is... lol...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Northern Fist
21
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 3rd Nov 2003 05:53 Edited at: 3rd Nov 2003 05:53
I think I just fixed it. It was no biggie. Basically you just have to play with the multipliers in the distance equation until you get the results you want. Thanks again for your help...

"Power, precision, and don't forget about speed. If you practice everyday with these things in mind... you begin to develope A FIGHTING MODE." - Fist of Legend (Jet Li)
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 3rd Nov 2003 07:46
Ah, ok... cool...
As i said, I'm just being a nice guy, lol...

Glad I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-21 09:48:43
Your offset time is: 2025-05-21 09:48:43