ULX

Author Topic: eye look pos  (Read 7082 times)

0 Members and 1 Guest are viewing this topic.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
eye look pos
« on: February 07, 2015, 04:14:03 AM »
Is there a way to make a player look at a position, I need an example if so, because garry's wiki is terrible and gives terrible examples.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: eye look pos
« Reply #1 on: February 07, 2015, 07:06:56 AM »
Well there's always code you could mess around with in here:
https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexaa2f.html
bw81@ulysses-forums ~ % whoami
Homepage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: eye look pos
« Reply #2 on: February 07, 2015, 04:15:13 PM »
http://wiki.garrysmod.com/page/GM/CalcView
Seems to have a decent example.
There's also EyeAngles(), and we use GetPos() in combination with it for some of our teleport commands.
I didn't look close, but presume when we get the EyeAngles and assign it to a player, then GetPos, then later SetPos that same player, is how we teleport and still have the player facing the same direction.
« Last Edit: February 07, 2015, 04:18:01 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: eye look pos
« Reply #3 on: February 07, 2015, 08:45:16 PM »
http://wiki.garrysmod.com/page/GM/CalcView
Seems to have a decent example.
There's also EyeAngles(), and we use GetPos() in combination with it for some of our teleport commands.
I didn't look close, but presume when we get the EyeAngles and assign it to a player, then GetPos, then later SetPos that same player, is how we teleport and still have the player facing the same direction.

Yeah, I looked through the teleport.lua and I commented things out to see if you were right, and well you weren't (unless I had misunderstood something you said). All !teleport does from what I saw is it takes the looking position, and just sends them there, thus never having to actually having to touch the looking position.

Basically I'm doing this for my addon "Set Spawn Points" -> http://forums.ulyssesmod.net/index.php/topic,8111.0.html

I'm trying to make it so that the player can continue the same direction as he was looking when he created the spawn point. Though, sadly, garry doesn't support straight forward answers, and likes everything really complicated.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: eye look pos
« Reply #4 on: February 07, 2015, 09:25:47 PM »
Now that you mention it, you're right.
Seen this though, right?
http://wiki.garrysmod.com/page/Player/SetEyeAngles
Shouldn't be hard to figure out... you set a vector and your player looks at it.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: eye look pos
« Reply #5 on: February 07, 2015, 10:22:24 PM »
Nope, I don't understand it at all. I can't even get my head around it at all. To my knowledge, I'm about to declare this literally impossible because garry couldn't just make it simple like "player is looking at this pos in his .HitPos so that means I want some magic function to make the player look at that .HitPos."

Nope, he makes all this useless stuff that no one really knows how to use.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: eye look pos
« Reply #6 on: February 08, 2015, 03:50:59 AM »
Just because you don't understand how some of the more involved functions in lua work, don't start thinking that something is impossible.
Turns out it's very easy to do.

Try this:
When you set a spawn save two angles.
GetAngles()
EyeAngles()

and then when they respawn or whatever just reset their positions:
SetAngles()
SetEyeAngles()

Turns out all you need is EyeAngles and SetEyeAngles. I just tested it in game.

Take a look:
Lua Example
« Last Edit: February 08, 2015, 04:12:16 AM by MrPresident »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: eye look pos
« Reply #7 on: February 08, 2015, 08:24:37 AM »
Wow Bite that Apple, if I've never pictured something someone being said in text before as being dramatic, I think now is definitely a first.


Get some rest. Sleep on it. If you just woke up and are reasonably rested, go focus on something else a while. Outdoors perhaps. :)
As MrPresident just demonstrated, the functions aren't that difficult. I understand that vectors can be challenging when trying to determine specific place in a map, but many functions already exist to grab them. If one doesn't already exist, go to the spot in the map and print player:GetPos() then add it to code.

« Last Edit: February 08, 2015, 08:28:34 AM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: eye look pos
« Reply #8 on: February 08, 2015, 10:58:15 AM »
Wow Bite that Apple, if I've never pictured something someone being said in text before as being dramatic, I think now is definitely a first.
Get some rest. Sleep on it. If you just woke up and are reasonably rested, go focus on something else a while. Outdoors perhaps. :)

Meh... honestly I was getting sick and tired of it. I had run into this problem before, and no one in the entire world of facepunch could help me and solve the issue, so it just annoyed me so {INSERT WORD HERE} much that I could never really get an answer. I had also been working on this project for three days, trying to get that part to work, so I had become really irritable.

Just because you don't understand how some of the more involved functions in lua work, don't start thinking that something is impossible.
Turns out it's very easy to do.

Turns out all you need is EyeAngles and SetEyeAngles. I just tested it in game.

As I typically same from time to time, "you can do anything and everything in garry's mod, with a little imagination", though this seemed impossible. I have not tested what you have provided me, I'm going to assume it works because you went out of your way to make a little video and inserted your community logo, some fancy text, and even went through the troublesome of actually doing it all.



Will edit this post if works:
« Last Edit: February 08, 2015, 11:00:43 AM by Bite That Apple »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: eye look pos
« Reply #9 on: February 08, 2015, 11:01:25 AM »
lol, I didn't go through the trouble of doing those things. :P

The community logo thing is automatically added to all of my videos on that youtube channel. One of the perks of having a partner account.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given