I want my camera to follow my player but when i get his position in other script it just falls outThis is the image of the script the script in the inspectorPlayerCameraPos
PLS HELPP
I only know that if i disable the script nothing happens the camera rotates and it stay in its position
Your plan should work, as long as:
The CameraPos script is attached to your MainCamera. (make sure!)
The "orientation" transform is set to the CameraPos object's transform.(it is)
The CameraPos object is a child of the Player (it is)
Nothing else is interfering with your MainCamera's position. (make sure!)
The code you've shown is fine – my guess is that if it's a code error, it's in a class that you haven't shown us – especially considering you mentioned your camera was rotating, and the class you screenshotted only applied a position.
Rotation can be really tricky — if you tried the four things I suggested without luck, try sending over your rotation code and we'll see if the problem is there.
Related
I have the Player move around and when he enters a new Room (via Instancing) his Sprite shows him facing in the Default direction (in my Case down). So If you enter a Room from any other direction then it looks weird, cause for a short Moment you can see the Player facing down even if you came from the right. How can I tell Godot to set the Player Sprite to a specific Frame in Code, so I can set it to the proper Frame for each Direction. I'm new to Godot and I used HeartBeast Action RPG Tutorial for my Movement. So it's using an AnimationTree and AnimationPlayer. I tried "set_frame" but Godot just says it doesn't know the Method.
If you are following the tutorial series I think you are following (Godot Action RPG)… You are using an AnimationTree with AnimationNodeBlendSpace2D (BlendSpace2D).
The BlendSpace2D picks an animation based on an input vector "blend_position". This way you can use BlendSpace2D to pick an animation based on the direction of motion or the direction the player character is looking at. For example, you can "idle_up", "idle_down", "idle_left", and "idle_right" animations, and use BlendSpace2D to pick one in runtime based on a direction vector.
Thus, you need to set the "blend_position" of the BlendSpace2D like this:
animationTree.set("parameters/NameOfTheBlendSpàce2D/blend_position", vector)
Where:
animationTree is a variable set to the AnimationTree.
"NameOfTheBlendSpàce2D" is the name of the BlendSpace2D you want to set (e.g. "Idle").
vector is a Vector2D with the direction you want (e.g. Vector2.UP).
This is shown in the episode 6 of the tutorial series (Animation in all directions with an AnimationTree).
You can find a reference project by HeartBeast at arpg-reference, where you can find a function update_animation_blend_positions that looks like this:
func update_animation_blend_positions():
animationTree.set("parameters/Idle/blend_position", input_vector)
animationTree.set("parameters/Run/blend_position", input_vector)
animationTree.set("parameters/Attack/blend_position", input_vector)
animationTree.set("parameters/Roll/blend_position", input_vector)
Here "Idle", "Run", "Attack", and "Roll" are BlendSpace2D, each configured with animations for the corresponding actions, and this function updates them in sync so that they are picking the correct animation.
As far as I can tell the code from the repository is further refactored from what is show in the tutorial series. This code from the repository is under MIT licence.
I can't find a way to get the actual camera direction neither in first person mode nor in third person: the vertical element of the data is missing, it's just constantly shows zero. I'v tried to get the camera data using PhysicsCast.instance.getRayFromCamera() and also by Camera.instance.rotation
None of them work. Also I found an older project, this one
https://github.com/NoahWarnke/DCLBlocks and within the new decentraland version it also doesn't work as it's supposed to be working. Is there a way to get the actual camera direction, pointer direction in the new Decentraland version?
I have a car moving on a road and the camera is updating its position and target to look at the car as it moves.
I am getting the strangest world shake/jittering.
cameraOrbitControls.object.position.set(cameraPosX, cameraPosY, cameraPosZ)
cameraOrbitControls.target.set(carNewPosition.x, carNewPosition.y, carNewPosition.z)
https://youtu.be/rAJyegrYPb8
However, i have narrowed the problem down to the camera target.set() call. When i remove this line the problem goes away, but its obviously not tracking the car how i would like anymore.
cameraOrbitControls.object.position.set(cameraPosX, cameraPosY, cameraPosZ)
// cameraOrbitControls.target.set(carNewPosition.x, carNewPosition.y, carNewPosition.z)
https://youtu.be/aia90b0z67Q
It feels like there is some bad matrix multiplication going on in target.set(...). Can anyone please explain this strange behavior?
(yes i have logarithmicDepthBuffer enabled and no sadly i cannot make this into a jsfiddle)
This answer provides a nice way to make smooth animations in SciLab. I now have to write a simulation of a body attached to two strings (and therefore its movement regarding some additional forces).
The code in the link works well to render movement of a single point and, unfortunately, I didn't manage to make an animation of a point + two lines using this method. If someone is curious, I tried this code to do it:
frametime=(tk-t0)/Nt//defining the waitnig time
plot(Y(1,1),Y(2,1),"o")//plotting the point
plot([0;Y(1,1)],[0;Y(2,1)],style=1)
plot([D;Y(1,1)],[0;Y(2,1)],style=1)//plotting the two initial lines
h1_compound = gce();
h_point=h1_compound.children
h_point.mark_size = 20;
h_point.mark_background = 2;
h_line1=h_compound.children
h_line2=h_compound.children
//h_axes = gca();
//h_axes.data_bounds = [0,-1;10,1];
realtimeinit(frametime);
for i=1:Nt//my vectors have Nt points
realtime(i);//wait "frametime" seconds before drawing the new position
h_point.data=[Y(1,i),Y(2,i)];
h_line1.data=[[0;Y(1,i)],[0;Y(2,i)]]
h_line2.data=[[D;Y(1,i)],[0;Y(2,i)]]
end
The question is: is there any way to make an animation of three shapes without making axes blink (as it is with the window refreshment) or other wierd stuff?
Since you didn't create a MCVE I can't reproduce your exact problem. But you may try to add drawlater(); before, and drawnow(); after your data modification to see if it does help with blinking or not.
Or you may get much better looking result by saving your plots in every round with xs2gif and assemble the animation with another gifmaker progam (there are free online sites to do this, however with some limitations). If you need to present your result, you should do this step anyway.
I'm drawing a handful of lines (THREE.Line). Under some conditions, the line suddenly disappears from the screen. This happens frequently when one endpoint is far outside the camera's field of view, but the other one is definitely within the field of view. This also happens when the line crosses the camera's field of view, but both endpoints are far outside it.
I can temporarily fix it by setting frustumCulled to false for each line, but this isn't optimal since I might have thousands of lines in the scene.
Is this working as expected?
BTW, I'm using r68. I haven't had time to refactor my app to work with r69. I'm using the WebGLRenderer.
I needed avoiding lines to dissapear too.
Following Justin idea of frustumCulled I had to do
line.frustumCulled = false;
I thought it was
line.geometry.frustumCulled = false;
but I was wrong, you've to apply it on the line not on its geometry.
This works for me on version 0.70