How to Spawn an Object?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

ospen

New Member
Dec 13, 2001
9
0
0
Visit site
Say I wanted an action to trigger the creation of a pair of JumpBoots in a Player's inventory, what's the code for the object creation bit?

I want the object to spawn directly in a player's inventory. I've tried using Spawn(), but I'm having problems.
 

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
46
Look outside your window!
Visit site
Here ya go, as defined in the Actor class:
Code:
//
// Spawn an actor. Returns an actor of the specified class, not
// of class Actor (this is hardcoded in the compiler). Returns None
// if the actor could not be spawned (either the actor wouldn't fit in
// the specified location, or the actor list is full).
// Defaults to spawning at the spawner's location.
//
native(278) final function actor Spawn
(
	class<actor>      SpawnClass,
	optional actor     SpawnOwner,
	optional name    SpawnTag,
	optional vector   SpawnLocation,
	optional rotator  SpawnRotation
);
To give it to the pawn who triggered the event it would be:
Code:
function Trigger( actor Other, pawn EventInstigator )
{
     local UT_JumpBoots JB;

     JB = Spawn(class'UT_JumpBoots', EventInstigator,, EventInstigator.Location);

     JB.GiveTo(EventInstigator);
     JB.bHeldItem = true;
}
 
Last edited: