Scripts / Change Camera Height in a third person game

Author
Message
LeGugusse
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 9th Dec 2020 21:17
Hello,

I'm working on a third person topdown view game and I would like to change dynamically the camera zoom (or camera height) during the game.





The script is working (prompting informations) but t produces nothing when E is pressed.

Another question: is it possible to use the mouse rolling to create a zooming / unzooming effect during the game?

Thank you for your help.
Cry \"Havoc!\" and let slip the dogs of war

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 9th Dec 2020 22:08
gameplayercontrol.lua handles all the camera/player positioning (amongst a ton of other things). So before you can take over control of it yourself you have to either edit that script to suit or disable the parts of it you don't want and do it all in your own script(s).

To take complete control of the camera you call SetCameraOverride ( 3 ) from inside your own script.

Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Dec 2020 13:08 Edited at: 10th Dec 2020 13:09
this will let you scroll the mouse to zoom in and out -press 'E' to reset the camera to move again
you can also hold 'E' to move the camera up and back a little to show how to do a fixed camera position.
should be enough there to show you how to achieve whatever it is you are trying to do

obviously this is just a very quick and dirty way of doing it - the best way would be to rewrite the core logic as amen suggests but don't expect it to be quick or easy
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
LeGugusse
17
Years of Service
User Offline
Joined: 15th Feb 2007
Location: Paris - France
Posted: 21st Dec 2020 18:39
Thank you so much!
That's really great!
My only problem with your script is that as soon as I zoom, or I am in a zoom mode, I can't move my character.
I can turn, shoot but moving is impossible...
Cry \"Havoc!\" and let slip the dogs of war
PM
Nevin
8
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 24th Dec 2020 16:53 Edited at: 24th Dec 2020 17:07
This is for changing fov.

just a copy paste of what I did to get this working. Im not sure if I made some adjustments to the gameplayercontrol script. game_pause, drive_on_map, zoom, g_mousewheellast, and g_fov are my own variables for my game. Like I said just a copy paste.. I hope this helps , or at least is a stepping stone

-- zoom in and out
if game_pause == 0 and g_drive_on_map == 0 then
zoom = g_MouseWheel - g_mousewheellast
g_mousewheellast = g_MouseWheel
if zoom < 0 and g_fov < 60 and g_pressed == 0 then
g_fov=g_fov+2
SetCameraPanelFOV(g_fov)
end
if zoom > 25 and g_fov > 25 and g_pressed == 0 then
g_fov=g_fov-2
SetCameraPanelFOV(g_fov)
end
if g_fov < 25 then
g_fov=25
end
if g_fov > 40 then -- 40
g_fov=40
end
end

Login to post a reply

Server time is: 2024-04-25 15:05:58
Your offset time is: 2024-04-25 15:05:58