How to set a Sprite to a specific Frame in Godot - animation

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.

Related

My player falls out when i get his position in unity

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.

Define timeframe for animation in KML

Is there any possibility to define a timewindow for an animation of KML objects? Like if i have to occurences animated (polygon 1 appears on the 1/1/2018 and polygon 2 on the 6/10/2018). Is there any way to define that the whole animation should last for f.e. 30 or 45 seconds? I only see that Google Earth always interpolates the animation time depending on the given
<TimeSpan> <begin> 2004-03 </begin> <end>2004-04</end></TimeSpan>
dates of the document.
In the current Google Earth Pro interface, there is no way to specify the duration (in playback-time) of an animation like this. As you noted, it expands the time slider to include the dates & times from all loaded KMLs, and plays across the slider at a preset speed (adjustable in the slider settings).
One way you could apply time playback with precise control is to set up a KML Tour which animates between two views (with time tags applied), over a specific number of seconds. Then you could have your user play it back using the Tour interface instead, and see the timing you want. Unfortunately KML Touring is rather complex with a long learning curve. There are simple things you can do (possibly including something like your request) using the tour recording interfaces in Earth Pro, but to really harness the full power of touring you'll need to create custom KML code, so consider yourself warned. :-)

Smooth animation of three shapes in SciLab

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.

How to make a third person character control walk based on where user is gazing through google cardboard in unity 3D

I am making a VR model of my university campus using unity3D.
I have created a model of my university and now my task is to make the third person character move in the direction where user will be gazing.
EX: if I look straight I should keep seeing which ever comes in the way .
If I look at left the 3rd person character should be able to turn left.
that means depending upon my head movement it should walk.
PL NOTE : I will be using Google cardboard VR Gear
How can I achieve it? I know I have to make a script in C# / javascript but I am not so familiar with it.
Please suggest !!!
Add your character as child of camera so it can rotate according to head movement. Then add your movement script to camera object and write code to move in forward direction. you can use controller or trigger to move it.

sf::View visibility Check

Ok, so I've been working on a game with some friends for a school project. We have used SFML.
I've been working lately on the camera and a tile implementations system and now I need them to work together.
The camera works like this:
I have two different sf::View, one for the game world and one for the hud. The one for the game world follows the player in the x-axis.
The tile system works in a way where it reads in a txt file and draw sprites based on the information from the txt file.
As it is now I always draw all the tiles, even if it's outside of the cameras view. Not good. I need a way to check if the tiles are outside of the cameras view before I draw them. How do I do this?
I did find this:
Get X and Y offset of sf::View
but I can't really wrap my head around how to make this info work in my game.
Any help would be really appreciated! :)
Mvh Elis
Managed to figure it out after finding this:
http://fr.sfml-dev.org/forums/index.php?topic=10590.0

Resources