Is it possible to destroy a prefab with code from another prefab? - spawning

I have a frog in my 2d game. It has an attack where it sticks its tongue out. I didn't make an animation for this, I made tongue fragment prefabs that spawn one after another. They obviously start at the frog's mouth. I want to make it look somewhat realistic, but since there are despawn timers in the tongue fragments, the tongue starts to disappear from the start of the tongue to the end of it. Is it possible to make them despawn with code in the prefab that spawns them?
I stated what I tried and what I expected in my details section.

Related

Snake game with pygame

I'm new to programming, and I wanted to start by making a snake game like snake.io. So as you can see by clicking the link below, I created the snake and all its movements, then I made a red border and coded the "health" of the snake, representing them with some upside-down triangles. What is supposed to happen is that each time the snake touches the red border, it should lose half a heart, and its "health" should go down. However, what actually happens is that I can't move anymore as soon as I touch the border, and my health goes down(since my health is printed in the output), but I don't lose any hearts(visually).
movement code
main part of the problem
I tried to change the entire code, but I was not too fond of it, so I switched back. Can you help me? Thanks.

How to get the position of a different object in gdscript?

I have a player, and I want to be able to detect when they are near a ball so they can press 'E' to kick it.
I'm new to godot and I'm probably just dumb but I can't figure out how to get the position of another object.
I have 3 separate scenes: MainScene(Node2D), Player(KinematicBody2D), and Ball(RigidBody2D). I want to attach a script to one of the scenes that detects how close the Player is to the Ball so they can kick it.
I'm not sure if I should attach the script to the MainScene, the Player scene, or the Ball scene and to be honest, I'm not entirely sure how the code should look. I'm not very familiar with the functions and the node/scene hierarchy is a little confusing.
I am familiar with Python, I just think I'm overwhelmed with this engine (its my first time using a game engine) and I'm having a bit of a tough time grasping it.
Any help would be greatly appreciated!
Side-quest: If you are feeling extra helpful I also need to figure out how to stop a RigidBody2D object from moving until the player hits 'E' on it to kick it!
For this you want an Area2D, which is purpose-built for "detecting nearby objects" without interacting with them physics-wise. Have an Area2D as a child of the Player node and connect the Player node to that Area2D's body_entered signal. Here's a tutorial on using Area2D for further info; this tutorial also links to various other tutorials that could be helpful.
i think you maybe use function
get_overlapping_bodies()
(of Area2D node) for detect another areas or body

How did Epic Games achieve this 3D effect on their Fortnite site?

I have been looking at Epic Games' Fortnites Website and I am trying to figure out how they achieved the 3D effect on the page:
Epic Games' Fortnite website - scrolled down to 3rd slide
Does any one have any idea how to do it? I would really like something similar to a project I'm working on. I have found Three.js, but I am quite sure that is not the solution they went with.
For these types of questions, i can only recommend to install spector.js and have a look yourself. In short: everything you see is 100% faked.
I mean, that's always the case. In fact, if you want to build something like that, your first question should always be: how much of this can I fake and still get away with that?
In this example, it turns out: everything. Just open the devtools and click through all the assets in the network-tab. You will find these two textures:
looks familiar, right?
So what they appear to be doing is they are using three.js with some custom shaders to handle the translations, the flickering of the lights and the highlighting. These effects are computed using the normal-map and an additional mask-texture which I couldn't quite figure out what it does. But again, if you look at the scene in spector.js you can see the shaders used for every drawcall.
The only thing that is a bit more complex is the little robot-friend in the bottom left corner. But again, it's not 3d as in meshes and so on but rather a set of flat textured quads running a bones-animation thing.
I think that makes it a really great website after all.
Given that epic is building the unreal-engine I would suspect the original renders were done there. And I agree, the lighting looks really amazing :)
It is a simple parallax effect using animated sprite sheets.
Parallax effect is achieved by using several layers of images/video on top of one another in different Z-depth.
You can achieve the moving part by using the mousemove event to track the cursor.

GtkFrame mystery: Different looks each time the program is started

This is really confusing the heck out of me. Take a look at this screenshot:
Sometimes, the GtkFrames in my program look like on the left side, and sometimes they look like on the right side - or even a mix of the two! The program is exactly the same. Just running the same program multiple times yields very different looks of the GtkFrames in the program! How can that be?
It seems that there are two different designs of GtkFrame:
The first one has its label centered at the top of the frame and
smoothly dissolves towards the
bottom so that the frame doesn't completely enclose the GtkFrame's
contents.
The second design has its label left-aligned at the top of the frame
and draws a border around the complete GtkFrame.
The problem is now that GTK+ seems to choose one of the two designs entirely at random. I don't see any pattern in which design I'm going to get. It appears to happen completely at random which is really confusing me.
Can somebody shed a light onto this mystery? What is going on here? Is there a way to force GTK+ to use a certain design?
I'm using GTK+ 2.24.10 with the Adwaita theme on Linux Mint.

How do I play two SoundEffectInstance variables in a row?

I'm making a game in XNA 4.0 and I want two sound effects to play in a row to form a sentence (e.g. The first sound effect may say "You have selected" while the second says "Game number 1"). The current code that I'm using makes the two sound effects play at the same time. How can I make them play one after the other?
soundEffectOne.Play();
soundEffectTwo.Play();
If you're calling both in the same update, then it makes sense that they'd both play at once.
You'll need to add in some functionality to check that the first sound effect has finished playing and then call the second effect.

Resources