How to make viewport object face mouse screen position.
So I want to make it so that like you know when you have things that face your mouse in screen?
So like the object will always face your mouse not in 2d, but in like a 3d viewportframe orientation you know what I mean.
So basically like visualise two planes. One plane where a 3d object is in the corner, and another where you can move your mouse on. The 3d object plane is slightly behind the mouse plane, so the mouse facing ray will be 3d because of the distance between the planes.
If you are asking for a script, I am asking for one too. There is no need for a script basis in this quetin.
I just want to get a script/example doing it
So my understanding is that in the example you’ve given, the head in the corner will look down at your mouse.
This means rotating the model along the Y-axis when your mouse is moving along the screen’s X-axis (so the head moves left and right), and rotating along the X-axis as your mouse moves along the screen’s Y-axis (to make the head move up and down). No rotation would be required along the model’s Z-axis, as this would cause the face to turn upside down.
I’m not totally sure on the maths for this, but just trying to clear up exactly what you’re getting at. This would be something I’d have to play around with for a while until I got the desired effect.
Love the concept though. It’s one of those little microinteractions that really adds to the feel of a game.
You’d really be looking to determine where the centre of the model is on the screen, and calculating the rotation from the offset (limited by the screen size, and how far the model should be allowed to rotate).
Are you sure you understand what I am speaking about? There is nothing about first person and FOV. this is about something on viewportframe face mouse position with z offset give cool effect do you see animtion?
I don’t think you could really make the guy face a point in 3D view without fixing the mouse in the center of the screen, but you could add a fixed amount of degrees on that player camera on both the X and Y coordinates and use the player’s mouse position on the 2D screen space, because if you try to rotate the camera to the mouse’s 3D position without centering the mouse then the mouse will keep on forcing the camera to rotate, Here is an example
the current look direction is the straight line while the mouse point is the arrow, if the mouse was not centered, then in the next frame it will still look in the right direction and will still make the camera rotate with it
while wait() do
for i,v in pairs(script.Parent.ViewportFrame:GetChildren()) do
if v.Name~="Cam" then
local x,y,z = CFrame.new(Vector3.new(game.Players.LocalPlayer:GetMouse().ViewSizeX,0,0),Vector3.new(game.Players.LocalPlayer:GetMouse().X,-game.Players.LocalPlayer:GetMouse().Y,1000)):ToOrientation()
game:GetService("TweenService"):Create(v,TweenInfo.new(.4,Enum.EasingStyle.Quint),{Orientation = Vector3.new(x*25,-(100-((y*125)/5)),z)}):Play()
end
end
end