generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: CFrame.Angles and lookVector...

Previous Thread :: Next Thread 
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 04:34 PM
Here I come with my daily question, as I'm yet again spending too much time trying make this work....

So I have:
rotation = CFrame.Angles(0,180,0)
camera.CoordinateFrame = CFrame.new()
*rotation
*CFrame.new(0,0,15)
*CFrame.Angles(math.rad(-15),0,0)
+ character.Head.CFrame.p
+ Vector3.new(0,4,0)
rotation is a point around the object, I need to convert the point character.Head.lookVector*-1 would give me into a usable angle.

A visual example: http://i.imgbomb.com/TI6RD.jpg
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 04:56 PM
Line 1, CFrame.Angles takes all arguments in radians
rotation = CFrame.Angles(0, math.pi, 0)
rotation = CFrame.Angles(0, math.rad(180), 0)

Um, you want to rotate the camera 15 studs back and 4 studs up of the lookVector of the head right?
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 05:03 PM
oops, yeah in my script I give it radians. Anyways, you are correct, but the way my script works is the camera rotates around the player with 'a' and 'd' using the variable rotation. What I need to do is get the correct angle that would place the camera behind the player when a key is pressed. maybe something with toObjectSpace?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 05:04 PM
The lookVector of the back of the head is:
Head.CFrame:vectorToWorldSpace(Vector3.new(0, 0, 1))
or
Head.CFrame.lookVector * -1

You could just place it there and multiply it by however far you want it
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 05:25 PM
I guess I'm not translating what i'm trying to do very well.

Say I have a circle with points 0-360, 0 and 360 being the same. Then inside this circle there is a block. I want to know where the back side of the block lies on the circle. Then if i know here it lies on the circle I can have CFrame.Angles(0,ThatPointOnTheCircle,0)

Still though, thanks for helping me out on my last couple questions. :p
Report Abuse
CitreIthkarr is not online. CitreIthkarr
Joined: 09 Jan 2014
Total Posts: 454
11 Jan 2014 05:32 PM
I think I have the solution to your problem

unfortunately I need to go in 5 minuites and don't have the time to type it up at this second
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 05:36 PM
"I want to know where the back side of the block lies on the circle. "
Yeah, it's this I don't understand. I'll re-look at the picture
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 05:45 PM
Lol, I overcomplicated this. 180 is what I was looking for, and all I was looking for. CFrame.Angles(0,math.rad(180,0) will always give me the back side of the player.

*Double face palm*
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 05:49 PM
that was a lie. I still need CFrame.Angles(0,math.rad(180),0) relative to the head. :|
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 05:53 PM
So you want the back look vector? 180 degrees of the lookVector?
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 06:01 PM
I'm not sure anymore D:

I was just re-creating the camera from Zelda: Majora's Mask, needed to flip the camera to the back of the player by the press of a key without interfering with the rotation values. Don't have a problem flipping the camera to front or back (rotation*CFrame.Angles(0,math.rad(180),0) does the job, but behind the player has created this mess...
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 06:04 PM
Can you upload this to a place so I can see what you mean lol
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 06:32 PM
You can see it here: http://www.roblox.com/Clock-Town-place?id=11676059
and the code here: pastebin.com/Z9k69q1j
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 06:41 PM
Does the KeyDown event actually give you a/d?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 06:47 PM
Ignore that last statement.
Nothing at all is happening in game
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 06:47 PM
yup.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 06:51 PM
I think I understand what you want:

When they move, the camera is always facing forward?
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 07:04 PM
Took me a bit to find an example from the game(internet is really slow atm), but here http://youtu.be/DaoR7nVBlGk?t=1m42s you can see how the camera works.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 07:07 PM
The part where he focuses? (in Wind Waker/Twilight, when you click "L" (GC))
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 07:13 PM
Yup, pretty much. L/Z-Targeting system is what i'm working on, but I right now I just want to rotate the camera to the back of the player(like when there's no target and you press L/Z)
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
11 Jan 2014 07:14 PM
change the camera to Follow and then change it back
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 07:16 PM
camera.CoordinateFrame = CFrame.new(Head.Position, Head.CFrame.lookVector) * CFrame.new(0, 0, 15) + Vector3.new(0, 4, 0)

It might work, hopefully
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 07:25 PM
No, I don't think that would work... Try this

camera.CoordinateFrame = Head.CFrame * CFrame.new(0, 0, 15) + Vector3.new(0, 4, 0)
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 Jan 2014 07:44 PM
yeah, that works to place the camera behind the player, but it also locks it there. What I have allows player to rotate independent of the camera, but pressing 'a' and 'd' rotate left and right around the head, so walking right would cause the camera to rotate to the right with player, which also enables set a turn radius by changing how fast the camera rotates. Then you can still turn toward the camera without it rotating with the character.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2014 07:49 PM
You could do this:

Head.CFrame * CFrame.Angles(0, angle, 0) * CFrame.new(0, 0, 15) + Vector3.new(0, 4, 0)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image