|
1 registered members (Quad),
6,361
guests, and 4
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
3rd Person Camera + Lag + Collsion detection
#101704
12/10/06 07:12
12/10/06 07:12
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
OP
Serious User
|
OP
Serious User
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]
#101707
12/11/06 00:43
12/11/06 00:43
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
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
vlau
OP
Serious User
|
OP
Serious User
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
HeelX
Senior Expert
|
Senior Expert
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
vlau
OP
Serious User
|
OP
Serious User
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]
#101712
12/13/06 20:48
12/13/06 20:48
|
Joined: Mar 2006
Posts: 2,758 Antwerp,Belgium
frazzle
Expert
|
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
vlau
OP
Serious User
|
OP
Serious User
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.
|
|
|
|