The problem is that I want to use OtherCharacter->AddWeapon() in the constructor of my character.
But since it was a Pickup, I just needed to pass the pickup itself to add to the inventory.
When I’m in the Character class, how do I add a new Pistol?
It’s like the Character pickups the pistol at the begin play
I heard about SpawnActor, but that spawns an actor in the WORLD.
Instead, I want my actor to spawn in the inventory of the character.
You can still use SpawnActor and instantly move the weapon to the character’s inventory. This will be result in the weapon being placed on the map depending on what Transform you feed the function, so you’ll have to initialize it invisible (SetVisibility) and probably also disable its collision (SetActorEnableCollision),
Actually, weapons are Blueprints Childs inheriting from a C++ Parent Class
So I need SpawnActor to actually spawn the Pistol Blueprint in the same location of the player character.
How?
---------------- 2nd question ----------------
Is it a good practice to spawn a Weapon into the world and set it as Invisible and No-Collision? We are spawning something in the World that won’t be really used
Is it a good practice to spawn a Weapon into the world and set it as Invisible and No-Collision?
We are spawning something in the World that won’t be really used
If an object is never supposed to be visible in the world, you could make it a UObject instead, which doesn’t have a transformation. (On the other hand, you mentioned that its location needed to be the same as the player’s…)
Yeah, that can be confusing. SpawnActor is overloaded a couple of times with different parameter sets. Visual Studio’s intellisense system usually suggests a couple of them when you start typing the function.
Nothing wrong with using the FVector version if you don’t need the scale.
The compile error is confusing because the compiler appears to have recognised the correct function signature (FTransform) but is still trying to convert it to FVector, which is strange. Usually when I get such an error, one of the references is an incorrect type (const vs. non-const or reference/pointer).