Gamestudio Links
Zorro Links
Newest Posts
FXCM demo test failed
by qin. 01/13/26 13:53
Camera always moves upwards?
by NeoDumont. 01/12/26 09:39
Alpaca Plugin v1.5.2 Release
by kzhao. 01/11/26 13:42
Alpaca Plugin v1.4.0
by kzhao. 01/11/26 13:38
separating groups of 3 digits by a comma
by joe_kane. 01/11/26 00:01
MRC.c and WFO
by joe_kane. 01/10/26 23:58
BarOffset (default = 940 for daily bars?
by joe_kane. 01/10/26 23:46
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (Quad, TipmyPip), 6,316 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
promfast, joe_kane, Namitha_NN, Syndrela, agasior
19190 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
3rd Person Camera + Lag + Collsion detection #101704
12/10/06 07:12
12/10/06 07:12
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Hello all,

I've a little x'mas gift for you, a simple level with
third person camera + camera lag + collision detection
code. Here is the download link

Hope you like it

Re: 3rd Person Camera + Lag + Collsion detection [Re: vlau] #101705
12/10/06 13:09
12/10/06 13:09
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Thank you, vlau. camera lag is one of frequently discussed script, so thanks for sharing completed level to show how to do it.

Re: 3rd Person Camera + Lag + Collsion detection [Re: Lion_Ts] #101706
12/10/06 15:16
12/10/06 15:16
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
@Lion_Ts, you're welcome as always.

@All, would you mind to leave some comments after you drive the poor
guard walking, turning and bumping into the wall

Re: 3rd Person Camera + Lag + Collsion detection [Re: vlau] #101707
12/11/06 00:43
12/11/06 00:43
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
To be honest, I expected more (by reading the headline).

Its nice that you share your code (and I'm sure someone will copy and paste it) but I wouldnt advice it for several reasons. I dont know your programming skills. So, if you are a beginner, its okay.

Some things I would do a bit different:
  • seperate the player code from the camera code, put all camera code in one function and call it each frame
  • your lag is done explicitely: instead of doing it by a variable that serves as lag by holding an angle which is decreased, you should let it work implicitely: the camera knows an offset and some angle parameters such as tilt and maybe arcus, but the lag is done between current cam position, calculated cam position and a interpolated position done by factor*time_step (i.e. 0.1*time_step) and vec_lerp. This is much more natural and dynamic
  • your camera collision is not a real collision: its more a worse exception. I'm sorry, but tilting it upwards is an ugly workaround. You will have more success by using one or two trace rays to determine a) collides my camera with a wall and b) where can I place my camera instead. Imagine you would move inside a room: you won't have an chance with your tilt solution.
  • try to rotate and move your player with accelerate: at the moment the model moves too mechanic


When you focus more on these alternative approaches, I'm sure, its the lesson worth it and you could re-release a second demo for contribution.

Re: 3rd Person Camera + Lag + Collsion detection [Re: HeelX] #101708
12/11/06 10:46
12/11/06 10:46
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Hi HeelX,

I'm so appreciate for your comments. I won't talk about my experiences here
because nobody are interested

I think seperate the player code from the camera code is not necessary because
this demo is tackle for camera lag and collision and the player control codes
is just only few lines, unless the camera code is applied to multiple players.

For the camera lag, to be honest, I'm not sure it is good or bad, since I haven't
seen any similar codes in the community, but I think it is the easiest way to do
that. The camera collision is also difficult to handle, casting multiple trace to
find a good position without burried into walls will slow down performance, place
it on top is better than left/right/front because you still have the same view
aspect while turning the player. Resume the camera tilt to the normal position is
a gimmick just want to have a nice transition, I admit it could be a problem.

As I said previously, this demo is tackle for camera lag + collision, I won't
expect too much on the player animations.

Anyway, your suggestions are professional and positive, but if the codes are
too complicate and difficult to read, people will lost their interests to study
and just copy and paste as you said.

Quote:


When you focus more on these alternative approaches, I'm sure, its the lesson
worth it and you could re-release a second demo for contribution.





I'm not sure I'll contribute the second demo, I'm expect other forum members
willing to contribute their works, people can help each other and the community
will grow better and better.

Re: 3rd Person Camera + Lag + Collsion detection [Re: vlau] #101709
12/11/06 15:40
12/11/06 15:40
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Okay, it seems you are satisfied with your code.

To bring it up again: intermingled code elements which are totally apart from each other should be seperated. I'm used to write an abstract movement routine for all actors (player+AI), a unified camera routine, abstract input routine (inserts input data for the player from the keyboard and when its AI, from the world recognition sub-routines), abstract event handling.. etc.pp. so that it really doesnt matter which entity is the player or not and everything is relative stable for both types (AI/player) and easily extendable.

OK, I have to admit that this doesnt relate to your code snippet in here, but I wanted to mention it as a part of a general discussion .. my thoughts were floating in the haze of my dark programmers cave

Re: 3rd Person Camera + Lag + Collsion detection [Re: HeelX] #101710
12/11/06 16:39
12/11/06 16:39
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
I remember when I working for my previous company, I've several programmers in my team,
they always ask me the same question : How to write good codes? and my answer is always
the same : Easy to read and understand by other people, no bugs and get the job done
in time. As I study their codes individually, I found that they have different style in writing
their codes but the result are just the same.

No offence and not direct to your comments, you just bring up my memories in the old days

Re: 3rd Person Camera + Lag + Collsion detection [Re: vlau] #101711
12/13/06 07:59
12/13/06 07:59
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
It seems not many people like my gift, or my comments

Re: 3rd Person Camera + Lag + Collsion detection [Re: vlau] #101712
12/13/06 20:48
12/13/06 20:48
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Quote:

It seems not many people like my gift, or my comments




I like the gift you contributed, it's a nice camera 3rd person script
About the camera colliding with the wall, it's a nice solution for a well know problem in the 3rd person camera world but I rather like the camera focusing and zoming towards the player when the camera collides with something like a wall or sort like
Short, I like your gifts and your comments I don't like...
Nah, just kidding vlau, who doesn't love you

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: 3rd Person Camera + Lag + Collsion detection [Re: frazzle] #101713
12/14/06 07:02
12/14/06 07:02
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline OP
Serious User
vlau  Offline OP
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Hi Frazzle,

Thanks for you kind words. Its easy to change the camera position by
modifying these lines of codes :

tiltLag = -68;
vec_set(camera.x,camPos);
vec_rotate(camera.x,vector(my.pan,tiltLag,my.roll));
vec_add(camera.x,my.x);
vec_diff(temp,my.x,camera.x);
vec_to_angle(camera.pan,temp);

you may try it yourself.

You know, I'm not going to sell myself or my products here, so no
fancy level supplied, I just want to help other people and hope other
people would like to help me. My english is bad, I'm so sorry if
my comments make somebody feeling unhappy.


Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1