Jump to content

Camera mouvement ?


Gabriel
 Share

Recommended Posts

Parent the camera to a pivot and move the pivot, but rotate the camera. Use PointEntity on the pivot to align it to the target waypoint, and use PointEntity on the camera, to point to the look at target.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Let say these are your game components.

 

MyPivot:TPivot=CreatePivot()

MyCamera:TCamera=CreateCamera() ' Or any camera you use

MyTarget:TMesh=CreateCube()

 

MyPivot is used for moving trough space, MyCamera is, well camera smile.png , and MyTarget is entity you want your camera to look at.

 

So, in that case, you will do next in your main loop

 

'Move trough space

If KeyDown(KEY_W) MoveEntity(MyPivot, Vec3(0,0,1))

If KeyDown(KEY_S) MoveEntity(MyPivot, Vec3(0,0,-1))

If KeyDown(KEY_A) MoveEntity(MyPivot, Vec3(-1,0,0))

If KeyDown(KEY_D) MoveEntity(MyPivot, Vec3(1,0,0))

 

'Now align camera to corresponding position

PositionEntity(MyCamera,EntityPosition(MyPivot),1)

 

'And Finally lets turn camera to requested target

PointEntity(MyCamera,MyTarget)

 

..and you are good to go..there are more advanced techniques to do this, but this is good enough to get you up and running..and one small tip...ALWAYS avoid parenting...ALWAYS..I hope it helps..

 

Link to comment
Share on other sites

..when your structure grows, and your classes are nested inside each other, parented entities you using/accessing in different classes are a nightmare to deal with considering all transformations applied to child if parent is modified on any way..this easy came in to picture with animation, particularly cut scene animations where same character/camera acting as a gamplay driven as well as cut scene character/camera...if your 3rd perspective camera is attached to that particular character and at same time involved in to cut scene, where camera/characters are utilized by external keyframing data,you will have entire set of variables as an offset from original state where whole process started..just one of the examples...if you using custom made math lib for specific purpose, things getting even worse..

 

Link to comment
Share on other sites

I avoid parenting too, especially with character controllers and models. Have run into all sorts of weird issues in the past when I was developing my path finding. I always now just manually up date the models position/rotation etc based on the character controllers for a trouble free life!

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Oups sorry, I want to move the camera from point "A" to point "B" to point "C" and look at direction "(target)"

 

 

Thank

 

see picture ;-)

 

First of all you need to write script for camera movement smooth path.

Here's good example, but in actionscript.

http://actionsnippet.com/?p=1031

 

In result you must get path object that will be store all points on path, and one function to return smooth coordinates along path, where path will be started at 0 and finish on 1

 

And while camera will moves along this path, point it to target.

 

Like (in lua)

 

......

path=create_path()
path.add_point(x,y,z)
path.add_point(x,y,z)
path.add_point(x,y,z)
path.add_point(x,y,z)
path.add_point(x,y,z)
path.build()

t=0

while KeyHit(KEY_ESCAPE)~=1 or t<1 do

t=t+.01
xyz=path.get_coords(t)

PositionEntity(camera,xyz)
PointEntity(camera,target)
RenderWorld()
Flip(1)

end

"Better" is big enemy of "good"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...