I'm trying to spawn new actors from by a constomized console command during game play, (after click play in Editor).
I tried WorldPtr = GEditor->GetEditorWorldContext().World(), then WorldPtr->SpawnActor<ActorClass>. But the spwaned actor only shown after play stops. I have to begin play again to see these actors.
I also tried get world from game play GameEngine->GetGameWorld(), then use that world to spawn actor, the actor can be seen in WorldOutliner Panel, but the actors is gone after play stops.
I wonder how can I spawn actors after begin play, and not disappear after play.
As far as I'm aware you cannot. Anything Spawned is destroyed when the session ends.
Why are you wanting them to stay? Have you looked into pausing, then ejecting from your player to inspect?
Related
NetworkServer.Spawn method spawns a gameobject, instantiated on server, to all clients. I have a canvas with UI for player. UI communicates with server through commands and RPCs. This canvas makes sense only to local player. There is no point in having these canvases instantiated on each player on client side. I`m trying to come up with a way to spawn one canvas for each player.
I`ve come across a suggestion to carry the canvas as disabled child object of player prefab and enable it with isLocalPlayer check. But I think that this solution is suboptimal for a type of game with loads of players.
I am following Unreal's tutorial titled Twin Stick Shooter with Blueprint. I am on the step called Respawning the Hero. I've done all of the instructions for that step, but when my player is respawned, they fall through the floor. I am using Unreal Engine 4.26.2 which is a different version than the tutorial uses.
In my game mode, I've tried all available settings of Collision Handling Override within Spawn Actor from Class. In the Class Defaults of my player, I've tried all options for Spawn Collision Handling Method. I've made sure that my PlayerStart is above the floor. None of the solutions I've found by searching have applied to my issue, as far as I can tell.
Thanks!
Within TwinStick Mode
Within HeroCharacter
Within HeroCharacter
Your HeroCharacter spawn location is not set. and thus the location is (0,0,0).
Connect output execution pin from Set Game Mode node to the Set Player Spawn Transform node.
enter image description hereso im basically new to blueprints and i am trying to make a game based on collecting trophies and i finished the code, but for some reason when i drag and drop the trophy it disappears, that wasnt an issue before, im also trying to randomize where the object spawns and i was succesful but after i made changes to the trophy code, suddenly it wont spawn at all, here are some screen shots. enter image description here
As I see you are destroying object on overlap, right before you respawn the object, you should destroy the trophy only after you spawn new, so destroy function must be called at the end, when other logic is finished.
And the best way to handle such operations is some kind of manager. You may use game mode, level, player controller as trophy manager, anything that will exist from the beggining of play and till the level is closed.
I am using Unreal Engine 4's visual blueprint scripting language to make a shotgun in my game. When I call the function fire, it simply spawns an actor at a given location (this actor moves like a bullet, and has a collision mesh). The only problem is when I want to add another "spawn actor from class" node to the event graph, both of the nodes stop working, and nothing happens. I tested to see if my for loop, select node combination was messing up, but it worked and printed out everything fine, but for some reason when the "spawn actor from class" node is put in more than once, it stops functioning.
Here are pictures provided, if you needed them, and feel free to ask any additional questions.
Here is the Imgur link: https://imgur.com/a/2ggqoAW
Can anyone please help me with this problem
Thank You.
As was stated in a comment, you should never use a for-loop in this way. Just use sequence node if you want to execute stuff in order. In your case, looping over the different transformations would be even better.
Also, don't use actors for projectiles. Actors are pretty heavy objects which require a lot of resources to create and maintain by the engine. A few hundred actors each ticking every frame can easily tank your framerate. Create a custom component and maybe have a look at UProjectileMovementComponent or EPIC's shooter tutorial project.
As for your current problem, check the collision handling, they might not spawn because they overlap when spawned.
How can I make sure an event finish playing even though I move around the listener in the 3D world at the same time. I only want to play the event at certain time with the same listener position as when the event started playing. Other event sounds needs to know where the listener is so I need to update the listener position. But I don't want the already started event sound to be effected...
You can register a callback with events so you know when they have finished. Event::setCallback and FMOD_EVENT_CALLBACKTYPE_EVENTFINISHED.
Perhaps you should consider keeping the listener stationary and only moving the events, that way once you start an event it will keep playing at the same position (unless you move it). It's hard to say without knowing exactly what you are trying to achieve.