Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[New G2O][Client-Side] OOP Camera Movement
#1
*Introduction:

NOTE! You have to enable event onRender via enableEvent_Render function

Info: You can support development of this code. Report me every bug below. I'll try to fix it.
NOTE! If you want to report a bug, make sure, that this isn't your fault!



Hi there community!
Not so long ago, i've decided to make a script implementation which allows to create camera animations.
Those animations are based on key position of the camera, you simply create a new object of the class called CameraMovement then, add some key positions, and play the whole animation.
I've made this script inspired by Tommy's work, i encourage you (if you want to use it) to send me some ideas to improve it even more!
You can freely use this script without any consequences.



*Video presentation:







Download



*Classes informations:



* class CameraMovement:



class constructor CameraMovement(string world = defaultWorld) // this argument is optional, you can set the world (.ZEN) of camera animation



*List of attributes:

NOTE! Informations about access to attributes are only recommendation to use them in specific way.
You always have full access to attributes.




fullaccess array CameraMovement.frames // This property points to array of frames. You can for example extract frame position (silly example): object.frames[0].position.x
readonly int CameraMovement.currentFrame // The id of current frame, it's equal to -1 on start, then 0, 1, 2, and so on
readonly bool CameraMovement.isMoving // Property equal true, when CameraMovement is active
fullaccess bool CameraMovement.repeat // This property defines if camera movement is looped (default is false), this means that when the animation is finished it will be repeated over and over again.
fullaccess string CameraMovement.world // This property defines camera world, you can change it if you need anytime.



*List of methods:



void CameraMovement.addFrame(table arguments)
{
// required arguments
array position //Camera key animation position

// optional arguments
array rotation //Camera key rotation, default is 0,0,0
int time //Time in miliseconds which will take to go to this key position, default is 4000
}

void CameraMovement.insertFrame(table arguments)
{
// required arguments
int id //The array slot in which will be added frame
array position //Camera key animation position

// optional arguments
array rotation //Camera key rotation, default is 0,0,0
int time //Time in miliseconds which will take to go to this key position, default is 4000
}

void CameraMovement.removeFrame(int frameId)//Removes frame at specified index

void CameraMovement.start() //Starts the camera movement
void CameraMovement.stop() //Stops the camera movement



*List of events:



onCameraMovementStart(CameraMovement camera) //This event is called when CameraMovement starts to move
onCameraMovementChangeFrame(CameraMovement camera, int newTargetFrameId) //This event is called when CameraMovement changes the targetFrame
onCameraMovementStop(CameraMovement camera) //This event is called when CameraMovement stops moving



*Basic example:



Squirrel Script
  1. // creating object
  2. local cam = CameraMovement()
  3.  
  4. // setting loop to true
  5. cam.repeat = true
  6.  
  7. // adding some frames
  8. cam.addFrame({position = [-1519, 114, 3023], rotation = [12, 54, 0], time = 4500})
  9. cam.addFrame({position = [-40, 370, 3192], rotation = [-8, 47, 0], time = 4000})
  10. cam.addFrame({position = [2, 389, 1380], rotation = [27, 153, 30], time = 4000})
  11. cam.addFrame({position = [365, 328, -402], rotation = [19, 245, 0], time = 4000})
  12. cam.addFrame({position = [-331, 620, -1834], rotation = [26, 161, 0], time = 4000})
  13. cam.addFrame({position = [79, 278, -4079], rotation = [10, 261, 0], time = 4500})
  14. cam.addFrame({position = [-943, 622, -4510], rotation = [18, 257, 0], time = 4000})
  15. cam.addFrame({position = [-4495, 129, -4345], rotation = [5, 254, 0], time = 4000})
  16. cam.addFrame({position = [-6379, 123, -4854], rotation = [4, 233, -30], time = 4500})
  17. cam.addFrame({position = [-7463, 357, -5558], rotation = [21, 186, 0], time = 4500})
  18. cam.addFrame({position = [-7693, 30, -6879], rotation = [3, 173, 45], time = 4000})
  19. cam.addFrame({position = [-7244, 402, -8276], rotation = [0, 157, 0], time = 4500})
  20. cam.addFrame({position = [-6423, 1083, -10918], rotation = [-2, 228, 0], time = 4000})
  21. cam.addFrame({position = [-7282, 1670, -17748], rotation = [27, 296, 11], time = 4000})
  22. cam.addFrame({position = [-9617, 774, -16942], rotation = [22, 291, 0], time = 4900})
  23. cam.addFrame({position = [-24802, 69, -8867], rotation = [1, 302, 0], time = 4800})
  24. cam.addFrame({position = [-26305, 241, -2403], rotation = [2, 447, 10], time = 4800})
  25. cam.addFrame({position = [-18533, 358, -1939], rotation = [0, 435, 0], time = 4500})
  26. cam.addFrame({position = [-4302, 342, 2814], rotation = [14, 473, 0], time = 4200})
  27.  
  28. addEventHandler("onInit",function()
  29. {
  30. cam.start() // playing camera animation after initialization
  31. })


Reply
#2
Small fix has been released.

I've forgot to add the default world variable, which ends up throwing an error, now this issue is no longer exists.
Also, i have some plans in near future to allow playing camera animation from end to begin.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [New G2O][Client] Free Camera Patrix 2 1,325 06.05.2020, 17:53
Last Post: Patrix
  [Client] Version check Quarchodron 2 1,346 25.08.2019, 13:06
Last Post: Quarchodron
  [Client] GUI Creator Quarchodron 6 2,436 12.08.2019, 22:05
Last Post: Arkhan
  [New G2O][Shared] OOP Area Manager Patrix 4 3,972 21.02.2019, 08:35
Last Post: Patrix
  [New G2O][Client-Side] bindKey Patrix 6 3,979 14.11.2018, 01:32
Last Post: Patrix
  [New G2O][Shared] Command Handler Patrix 3 2,735 05.09.2018, 14:42
Last Post: Patrix
  [New G2O][Shared] packetListener Patrix 3 2,952 20.06.2018, 17:43
Last Post: Tommy
  [0.1.4.*] [client/server] Simple anty-cheat Profesores 8 4,177 20.03.2018, 18:16
Last Post: Patrix
  [0.1.3] [client/server] BotCreator HammelGammel 22 11,383 08.02.2018, 21:02
Last Post: HammelGammel
  [0.1.3] [client/server] Utility Scripts HammelGammel 1 2,268 27.01.2018, 13:03
Last Post: HammelGammel

Forum Jump:


Users browsing this thread: 1 Guest(s)