Look Rotation: Difference between revisions

From Fancade Wiki
(Created page with "/uploads/Look Rotation.png Create a rotation pointing in a given direction, e.g. rotating a character to look that way. Inputs: * Direction: The direction you want to look in * Up: Which way is up for the looking character (defaults to [0, 1, 0] if unwired) Outputs: * Rotation: A rotation "looking" in the direction. == Notes == * When converting one direction (vector) into a rotation, there is actually an infinite number of solution...")
 
m (Fix red link)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[[width=336px,alt=Look Rotation|/uploads/Look Rotation.png]]
{{Block
|image=Look Rotation.png
|type=s
|folder=Math
|input1={{Port|v|Direction}}
|input2={{Port|v|Up}}
|output1={{Port|r}}
}}


Create a rotation pointing in a given direction, e.g. rotating a character to look that way.
Create a rotation pointing in a given direction, e.g. rotating a character to look that way.


Inputs:
* Direction: The direction you want to look in
* Up: Which way is up for the looking character (defaults to [0, 1, 0] if unwired)
Outputs:
* Rotation: A rotation "looking" in the direction.


== Notes ==
== Notes ==
 
* The Up vector defaults to (0,1,0) if unwired.
* When converting one direction (vector) into a rotation, there is actually an infinite number of solutions! You can visualise this by picking up an object, say a pencil, and point it in some direction. You'll notice that you can still spin the pencil (thus changing it's rotation) without changing the direction it's pointing. That's why we define a second "Up" vector. It helps define how the pencil should be oriented. (It can often be ignored, but is definitely needed if the default [0, 1, 0] is in the same plane as the Direction input.)
* When converting one direction (vector) into a rotation, there is actually an infinite number of solutions! You can visualize this by picking up an object, say a pencil, and point it in some direction. You'll notice that you can still spin the pencil (thus changing it's rotation) without changing the direction it's pointing. That's why we define a second "Up" vector. It helps define how the pencil should be oriented.


== Examples ==
== Examples ==


* Make an object point to another object:
* Make an object point to another object:
[[File:Screenshot_2022_1030_155921.png]]
: {{Image|Look rotation example1.png|Example}}
* [[Angle between two vectors]]
* [[Angle between two vectors]]
* Look rotation is also used to created inverse trigonometric functions. See the related script block: [[Break Rotation]]
* Look rotation is also used to create [[Break Rotation#Example|inverse trigonometric functions]].
 


[[Category:Blocks]]
[[Category:Blocks]]

Latest revision as of 12:29, 7 June 2024

Look Rotation
Look Rotation.png
TypeScript block
ColliderNone
FolderMath
Ports
Inputs Direction
Up
Outputs Rotation

Create a rotation pointing in a given direction, e.g. rotating a character to look that way.


Notes

  • The Up vector defaults to (0,1,0) if unwired.
  • When converting one direction (vector) into a rotation, there is actually an infinite number of solutions! You can visualize this by picking up an object, say a pencil, and point it in some direction. You'll notice that you can still spin the pencil (thus changing it's rotation) without changing the direction it's pointing. That's why we define a second "Up" vector. It helps define how the pencil should be oriented.

Examples

  • Make an object point to another object:
Example