Scripted player camera

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Scripted player camera

by MirceaKitsune » Thu Apr 10, 2014 16:06

Thread for pull #1215

I have created a Lua function which allows scripting the player's camera. You specify a position offset, rotation offset, FOV multiplier, and transition time. Additionally you can specify whether that's a third person viewpoint, in which case the wielded item is hidden and the player can see their own model.

One practical use is allowing players of different sizes to have a correct eye position... so a server can offer both giant and midget player models, while this makes it possible to define a proper camera height for each. Another is vehicles, which can now setup a behind view like any racing game when entered. Also beds, for which you can offset the location and rotation of the camera to make it look like you're laying down. It can also be used to change the FOV as an effect for specific actions... like being underwater or running. Many more uses can probably be found.

Note that this might invalidate existing "third person camera" patches, as it adds the ability to have a 3rd person camera but with a lot more features... no harm meant to the authors of those patches, since a choice between this and them might have to be taken. Also note that the local player model is still networked and will visually lag like any player on the server, which can probably be fixed later.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Thu Apr 10, 2014 16:12

MirceaKitsune wrote:One practical use is allowing players of different sizes to have a correct eye position.

That sounds fine, especially in combination with riding on animals/using vehicles. Also a position behind the vehicle sounds very intresting!

MirceaKitsune wrote:Also note that the local player model is still networked and will visually lag like any player on the server, which can probably be fixed later.

That's also a problem when you try to follow another player: There are just not enough updates. I've even considered writing a mod that allows to auto-follow someone who tries to lead you to his house...

Hope your patch gets merged.
A list of my mods can be found here.
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Thu Apr 10, 2014 17:27

This sounds like a promising prospect, MirceaKitsune. It is a shame that we don't see you around here more often.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Thu Apr 10, 2014 18:00

Inocudom wrote:This sounds like a promising prospect, MirceaKitsune. It is a shame that we don't see you around here more often.


Thanks. I'm always around, just more or less active at times. Don't think I'd ever leave Minetest ^^
 

User avatar
hoodedice
Member
 
Posts: 1372
Joined: Sat Jul 06, 2013 06:33

by hoodedice » Thu Apr 10, 2014 18:17

Can this be attached to *just* in front of the player model's head, and then the model be displayed at all times?
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Thu Apr 10, 2014 20:27

I discussed this on IRC and spoke with BlockMen. We agreed there are advantages and disadvantages in both my code and his. Mine allows setting camera position and rotation via Lua, but makes the server responsible with switching between 1st / 3rd person views which I agree isn't normal and should be client-side. There's also no detection of solid objects... my third person cameras would go into walls and not stick against the surface.

I asked him to add Lua offsets for both 1st and 3rd person views... something like player:set_camera_offset({1st_person_position}, {3rd_person_position}). Once that's in, we might later look into another function to attach the camera to entities other than the player... to make CCTV cameras / turrets / remote-controlled vehicles / mind controlled mobs possible.

So for now at least, I'm pausing this code. Watch #1114 and this thread and we'll see how it goes there :)
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Fri Apr 11, 2014 01:29

This would be great for cinematics. Like running a camera between two points.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

by paramat » Fri Apr 11, 2014 05:16

Sounds good, lots of potential.
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Fri Apr 11, 2014 07:50

Great addition! Is there any doc available?

MirceaKitsune wrote:Also note that the local player model is still networked and will visually lag like any player on the server, which can probably be fixed later.

Does it lags more with this patch then without? (With Blockmen's version it does.)
Last edited by 4aiman on Fri Apr 11, 2014 07:50, edited 1 time in total.
 

User avatar
hoodedice
Member
 
Posts: 1372
Joined: Sat Jul 06, 2013 06:33

by hoodedice » Fri Apr 11, 2014 09:25

4aiman wrote:Great addition! Is there any doc available?

MirceaKitsune wrote:Also note that the local player model is still networked and will visually lag like any player on the server, which can probably be fixed later.

Does it lags more with this patch then without? (With Blockmen's version it does.)


I would think so.

Also, what are your specs? My skeleton system runs BlockMen's 3D view with no lag.
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Fri Apr 11, 2014 11:53

Evergreen wrote:This would be great for cinematics. Like running a camera between two points.


With the approach in BlockMen's branch, the concept of "a 1st person camera and a 3rd person camera" would be hard coded, although Lua sets the positions for both. Cinematic views could somewhat be done by having nodes offset the 3rd person camera only, so the player only sees the effect while he chooses out-of-body view locally.

4aiman wrote:Great addition! Is there any doc available?

Does it lags more with this patch then without? (With Blockmen's version it does.)


I did document the function in my branch, although it's probably useless now. And yes... my code still leaves the local player be networked like all other players, so you still see yourself in server-side movement.

To fix this, we need to override the position and rotation of the local player's entity client side, to use the information we know locally about our position rather than having the server send it like for other players. When this is done, we should also stop the server from sending a player their own position / rotation, to no longer waste bandwidth unnecessarily.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sat Apr 12, 2014 21:04

BlockMen's third-person view code was added to Minetest GIT today. Go check it out! It has the eye offset feature, and sometime we can hopefully look into an ability to attach the camera on entities too.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 4 guests

cron