Scripts / Positioning player camera to look at entity

Author
Message
Flatlander
GameGuru Master
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 7th Jun 2017 22:00
Explanation of video. I start out by transporting to the demon caves. After I am transported I want to be looking at the poor soul chained to the wall. A normal transport will not point the camera in that direction. It's either pointing to the floor or to another wall; I'm not sure. After a lot of trial and error I find a way to do this with script; but, I still have problems. I'm still not sure if I'm using the commands in the right way or the right order but I do get an initial result that is positive. Now if you take a look at the video.



I have the full code below. The problem is that when control is given back to the engine (being able to utilize the mouse view) we are immediately looking down at the floor so the player never sees what is in front of him. It can only be seen because I stopped it with a prompt. Mouse view control will be given back to the engine after pressing 'E'.

I was excited at first because I thought I had come up with script to actually "rotate" the player to look at a specified entity. The main part of it is the ability to get the positional 3D coordinates of the enity using x = GetEntityPositionX ( 319 ), y, and z (see code). 319 is the number of the entity for my map. I would have thought that setting the camera position and angle would have been sufficient and it would retain that position after using the necessary commands. I also messed around with mouse xy coords to no avail. It always points to the floor.

Does anybody have any thoughts?



When in doubt -- C4 :heh, heh, heh:

-Jamie Hyneman
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Jun 2017 14:27 Edited at: 8th Jun 2017 14:28
can't you just use TransportToIfUsed(e)?
the player will be transported to the object and looking in the same direction as the object you transport to (only works for y value but that seems fine for your video).
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Flatlander
GameGuru Master
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 8th Jun 2017 16:46
For testing I'm using 'transportinzone' which uses 'TransportToIfUsed'. After transport the player is looking in the opposite direction. So I tried rotating the object to which he was transported in different directions. The player was always pointing in the same direction no matter how I rotated the 'ifused' object. I even used different objects to transport to with the same results. So, I thought about changing the camera angle after the player was transported.

I finally have something that works and only after hours of fiddling around with all sorts of commands. It was after I delved into the 'gameplayercontrols' that I narrowed it down. Here's the code. Remember the number '319' is the target entity.



The strange thing about this is that I have to enable 'SetCameraOverride'. I then disable the override in the next loop. I don't know, It might have to do with slowing the loop down.

I'm going to use this unless I find a simpler way. I might test some more different 'ifused' objects and different rotations again.
When in doubt -- C4 :heh, heh, heh:

-Jamie Hyneman
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Jun 2017 18:48 Edited at: 8th Jun 2017 18:52
ah yes, just tried and it doesn't account for the angle, now that i think more on it i believe it used to and it was removed, sorry.
your method seems fine though, if it works, it works
but another way to do it is to use the TransportToFreezePosition() command on an actual entity that you can rotate and place on the map, rather than a zone.
so

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 8th Jun 2017 19:18
I always though the TransportToIfUsed transported you facing the direction that you were facing when it triggered, that's always how it seems to me.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 8th Jun 2017 20:09
Quote: "I always though the TransportToIfUsed transported you facing the direction that you were facing when it triggered"

You are right.

It works fine for me with this code:



3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM

Login to post a reply

Server time is: 2024-12-23 05:16:54
Your offset time is: 2024-12-23 05:16:54