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 / Alternative Set Camera To Follow?

Author
Message
Mugen Wizardry
User Banned
Posted: 30th Aug 2011 15:55
Hi all, can someone please help me fix that god forsaken Set Camera To Follow?

When you rotate to a certain angle, instead of rotating all the way AROUND the character or object, it goes backwards? o.O

I need this fixed, while still having a smooth option.

Thanks!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 30th Aug 2011 17:19
Don't use it .

Here's a trick I like to use to get that functionality without any complicated math:


Mugen Wizardry
User Banned
Posted: 31st Aug 2011 00:00
Thanks, is there a way I can get the same functionality as set camera to follow, but without the weird glitch and with the smoothing?

Thanks!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Aug 2011 00:16
Mugen try this it uses smoothing:


29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 31st Aug 2011 00:55
If you're using the OBJECT ANGLE Y() command as the angle in the SET CAMERA TO FOLLOW command you will have a problem due to the way DBPro handles the angles of an object in 3D space.

The code below simply creates a cube and uses the TURN OBJECT LEFT command to rotate it. The angles of the object are then printed to screen. Notice how the Y angle is always between -90 and 90 and that the X and Z angles flip from 0 to 180. This gives the same visual affect as if the object was being rotated about the Y axis through 360 degrees



This is what makes it look as if the SET CAMERA TO FOLLOW command isn't working properly.

To get around this, you can use a variable to control the rotation of the object that is being followed and then use this variable in the SET CAMERA TO FOLLOW command as in the example below.

Mugen Wizardry
User Banned
Posted: 31st Aug 2011 02:03
OMG! THAT'S EPIC! Is there any way you can make it so that when i hold the down key, it rotates the cube backwards like im running backwards, and then slowly rotates the camera to the back of the model?

Thanks! =D

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Aug 2011 10:42
Assuming you mean 29 Games suggestion:


Mugen Wizardry
User Banned
Posted: 31st Aug 2011 15:20 Edited at: 31st Aug 2011 15:28
Thanks, Baxslash. However, I tried it, and it didn't work for some reason. o.o Also, the player needs to be able to be able to move forward when the camera is behind him. IE: The camera is behind the player, and the player technically moves backwards, but since the camera goes behind the player, the player technically moves forward

Do you see how the camera moves in this game?

http://www.youtube.com/watch?v=13xbhz2il5M This is EXACTLY what I need. This code is VERY close to what I need. It just needs a small tweak, and it will be perfect

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Aug 2011 15:33
Quote: "I tried it, and it didn't work for some reason"

What do you mean by it not working? It should have made the camera go to the other side of the character when you press downkey. Did that not happen?

Shadow of the colossus does not follow the angle of the character and has a target following system too. That's much more complicated.

Why not post your code and I'll take a look?

Mugen Wizardry
User Banned
Posted: 31st Aug 2011 15:34
There ya are!



Thanks, baxslash!

And no, it did not

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Aug 2011 15:42 Edited at: 31st Aug 2011 15:45
Aaah, yes... try this I forgot to include the set camera to follow command too:


EDIT: Added some tweeks so you can move backwards too...

Mugen Wizardry
User Banned
Posted: 31st Aug 2011 15:47
Thanks Baxslash. Only one SMALL problem. the player moves forwards when it should move backwards XD

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Aug 2011 15:49
Screwed that up totally... try this one!


Mugen Wizardry
User Banned
Posted: 31st Aug 2011 15:50 Edited at: 31st Aug 2011 15:55
To me, it's PERFECT! Thanks, Baxslash! I just want your opinion though. How close do you think it is to the Shadow Of The Colossus cam?

Also, I fgt. one SMALL detail. Is there a way to make it so that the camera waits for the player to reach a certain distance away from the camera, and then it slowly uses smoothing to zoom in to the player?

Thanks again!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Aug 2011 16:09
Quote: " I just want your opinion though. How close do you think it is to the Shadow Of The Colossus cam?"

Not a million miles off. You'd need to have it rotating towards a target or facing in a particular direction based on in-game occurances to be more like it. As I said it's not impossible, the main thing would be to have a target (dummy) object that the camera points at that constantly moves toward nearby targets. I could do an example but I'm low on time... give me a while I'll post some code.

Quote: "Also, I fgt. one SMALL detail. Is there a way to make it so that the camera waits for the player to reach a certain distance away from the camera, and then it slowly uses smoothing to zoom in to the player?"

Yes, that's possible using more complicated system too. I'll post my target code and see if it helps you along the way

Mugen Wizardry
User Banned
Posted: 31st Aug 2011 16:11
Thanks alot, Baxslash!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Mugen Wizardry
User Banned
Posted: 31st Aug 2011 17:17
I have an upgraded code. I need it so that if the player's y angle is NOT = to the behind of the object (-180 im assuming), then it locks the camera in place until the distance between the player and the camera is = 2, so that it appears as if the camera waits until the player turns completely around, THEN slowly follows the player. Same thing with the forward y angle. Also, why is it lagging a bit? o.o

Here's the code:



Thanks, baxslash!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 31st Aug 2011 17:18 Edited at: 31st Aug 2011 17:20
The smoothing isn't great but with some tweeking it should give you a system to point the camera at a target while keeping your player in view:


EDIT: If you get more than 100 units away from any target it will go back to your player...

EDIT2: I'll try to take a look at your wait code later (should be working now!

Mugen Wizardry
User Banned
Posted: 31st Aug 2011 17:22 Edited at: 31st Aug 2011 17:43
Thanks, Baxslash!

EDIT: Is there any way to reverse the controls once the camera "targets" an object? and when it stops targeting, reverse the controls back to normal? Also, we have a problem with the target system. If the object is too big, it targets the top of the object, not keeping the camera on the player

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Mugen Wizardry
User Banned
Posted: 1st Sep 2011 01:51
baxslash, have you had a chance to take a look?

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Sep 2011 12:04 Edited at: 1st Sep 2011 12:05
Quote: "Is there any way to reverse the controls once the camera "targets" an object? and when it stops targeting, reverse the controls back to normal? Also, we have a problem with the target system. If the object is too big, it targets the top of the object, not keeping the camera on the player"

What do you mean by "reverse the controls"?

If you always want to keep the player in view you'll have to work out the vertical angle to the target and adjust the camera height based on that (quick image to give you an idea how to proceed):


Mugen Wizardry
User Banned
Posted: 1st Sep 2011 14:42
I have NO idea how to do that. I'll just stick with the old code I guess.

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Sep 2011 15:04 Edited at: 1st Sep 2011 15:04
You could do that.

Learning about SIN, COS and TAN is pretty vital to 2D and 3D game making though. If I were you I'd use this as an opportunity to pick up some very handy knowledge.

Here's a quick breakdown based on your problem:
1-Get the angle between your character and your target object using (SOH-CAH-TOA)

Based on a right angled triangle-


SOH
Sin(angle) = Opp/Hyp
CAH
Cos(angle) = Adj/Hyp
TOA
Tan(angle) = Opp/Adj

...so...

TAN(angle#) = distY#/distXZ#

...or...

angle# = ATAN(distY#/distXZ#)

distY# = object position y(target) - object position y(player)

distX# = object position x(target) - object position x(player)
distZ# = object position z(target) - object position z(player)
distXZ# = sqrt(distX#^2 + distZ#^2) *Pythagoras therum*

put that back into here -> angle# = ATAN(distY#/distXZ#)

...now you have your angle!

Want me to continue?

Mugen Wizardry
User Banned
Posted: 1st Sep 2011 15:09
Why not? But I warn you. I'm HORRIBLE at math. But if you teach me the way I was meant to be taught (through code basically), then I will learn.

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 1st Sep 2011 16:18
I found that with Trigonometry, it was easier to start by using it in 2D, then progressing to 3D.

Mugen Wizardry
User Banned
Posted: 1st Sep 2011 16:23
Some people aren't as lucky as you. -.- I have a disability. I simply can't learn it.

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 1st Sep 2011 16:29
You said you can learn through code. If you first apply the maths in a very basic 2d movement project, for example, you can learn how it works. Then you can progress to 3D with a more stable knowledge of the concept.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Sep 2011 16:30 Edited at: 1st Sep 2011 16:30
Quote: "I simply can't learn it."

You can learn it. Aspergers can make a person extremely logical, Maths is logical. You can only not learn it if you do not believe you can learn it.

I may have made my first post a little too complicated? If so tell me and I'll take you through it one step at a time.

Quote: "I found that with Trigonometry, it was easier to start by using it in 2D, then progressing to 3D."

This is a good point. The problem we have here is a practical one though and it can be explained in a fairly simple 2D way.

Mugen Wizardry
User Banned
Posted: 1st Sep 2011 16:49
Yes, it's WAY too complicated. And I don't have just ANY type of asperger's syndrome. I have the EXACT same syndrome Albert Einstein had. He failed 2nd grade math.

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 1st Sep 2011 16:55
But Einstein was a brilliant mathematician regardless. We're just trying to help you here.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Sep 2011 16:57
I never heard of Albert Einstein having Aspergers, and he was very good at maths. The only reason that people say he wasn't good at maths is because he wasn't a maths Genius, he was an artistic genius... a thinker of 3D logical visualizations.

Mugen Wizardry
User Banned
Posted: 1st Sep 2011 16:57
I know, and I appreciate it. But it would help if you did it in a language I could understand.

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Sep 2011 17:03 Edited at: 1st Sep 2011 17:05
If you put an object behind the player like a box, and check collisions with it, it will rise up in the air behind the player. When the distance to the box in the Y is higher than the player you can use that Y with the camera Y, add them together, and point the camera at the player.

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 1st Sep 2011 17:07


I'm not great at explaining things, but hopefully that will help.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Sep 2011 17:08 Edited at: 1st Sep 2011 17:11
Actually he was a physicist but he did have a knack for formulas...

Let me start with the basics.

This is all based on right angled triangles. If you want to find the angle between two points in 2D and you know their positions in X and Y (x1,y1 & x2,y2) then you can work it out as follows:

First get the difference in X between the two points:


Next get the angle using the formula "tan(angle)=opp/adj", in order to get the "angle" we need to get it out of the tan() by applying atan() to both sides of the formula.

If we applied atan() to tan() they basically cancel each other out leaving you with "angle=atan(opp/adj). Putting our numbers in we get:


Once you have your head around that I'll show you the next stage.

EDIT: Wow, when did everybody join in?

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Sep 2011 17:14
Quote: "EDIT: Wow, when did everybody join in?"


I just wanted to give an alternative to maths, because I am also useless at maths.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Sep 2011 17:19
I used a similar method PP for checking when a 3D puzzle was finished in my game "Soma".

I tried to think of loads of different ways to check over 200 possible solutions and then one day I got the idea of doing a collision check for the extremities of the cube, worked a treat!

There are always other solutions but I figure learning at least this basic trig is essential for game makers. Or am I wrong?

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Sep 2011 17:23
You're not wrong, but Artists find maths hard, because the brain shares the same area. Finding alternatives is part of game making as well.

Mugen Wizardry
User Banned
Posted: 1st Sep 2011 17:27
When did everyone join in? Because everyone loves meh :3

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Sep 2011 17:31
Well you are trying...

Mugen Wizardry
User Banned
Posted: 1st Sep 2011 23:30
baxslash, instead of all this intense math, can you take a look at the code I gave you BEFORE the target system? If you can get the camera to lock on to the player until the user holds the down key and the player rotates backwards, that would be just fine

Thanks!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Sep 2011 23:59
I'm trying to help you to learn. This is not really 'intense' math but if you don't want to do that kind of stuff right now that's fine!

I'm not writing the whole thing for you either. Come on bird, try those wings!

Frankly I'm not 100% sure what you mean anyway, why would you want the player to turn around when the user presses down?

Mugen Wizardry
User Banned
Posted: 2nd Sep 2011 00:42
I need the movement of the player to work like a control stick on the PS2 That's why

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Sep 2011 01:06
Oh, you mean like the player movement in Grand Theft Auto?

I think I get it now, so if you press left and the character is facing right on screen he'll turn around and go left... I did a start of a game like that. Let me see if I still have it...

Mugen Wizardry
User Banned
Posted: 2nd Sep 2011 01:09
Yes. Basically the movement is 360 degrees And the camera follows the correct way. It locks on to the player until the player makes a move and is rotated to the correct y rotation

Thanks, Baxslash!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Sep 2011 01:14
Try the attached, if it's what you want I'll post the code...

Mugen Wizardry
User Banned
Posted: 2nd Sep 2011 01:18
yes. that's the way. except for when you walk backwards. can you make it so that it moves the way it does for back, like it does for all the other angles? such as forward?

Thanks, Baxslash!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Sep 2011 01:25
I'll post the code but it's using enhanced animations and dark lights so if you don't have those you'll need to strip it out but the movement and camera code seems fairly useable... you should be able to work out how to do the reverse walking thing, I'm working right now (11:30pm and I'm STILL working that's since 8am BTW)

If I get a chance I'll take another look but you can HAVE the code it's attached

Mugen Wizardry
User Banned
Posted: 2nd Sep 2011 01:25
Thanks ALOT, Baxslash! I really do appreciate it!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Mugen Wizardry
User Banned
Posted: 2nd Sep 2011 14:28
@Baxslash, I'm a little confused, as to how to reverse the player's "forward" capability.



i tried changing all negatives to positives, all positives to negatives, all +'s to -'s, and all -'s to +'s, and all 1's to 0's, and all 0's to 1's, and it still didn't work ><

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !

Login to post a reply

Server time is: 2026-07-10 06:07:16
Your offset time is: 2026-07-10 06:07:16