# How to spawn an actor from a plugin

**URL:** <https://forums.unrealengine.com/t/how-to-spawn-an-actor-from-a-plugin/340246>\
**Category:** Plugins\
**Tags:** spawn-actor-from-cla, unreal-engine, Plugins, question, CPP\
**Created:** [December 1, 2015, 7:35pm UTC](https://forums.unrealengine.com/t/how-to-spawn-an-actor-from-a-plugin/340246 "2015-12-01T19:35:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bleeck](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bleeck](https://forums.unrealengine.com/u/Bleeck)\
**Post date:** [December 1, 2015, 7:35pm UTC](https://forums.unrealengine.com/t/how-to-spawn-an-actor-from-a-plugin/340246/1 "2015-12-01T19:35:50Z")

</div>

Hi,

I’m working on a plugin and can’t seem to get it to spawn an actor for me. What I’m trying to do is the following :

- MySplineClass is a class that has a spline component (made from c++)
- I want, when I drag this into the editor, to spawn controller objects on each of the keys of the spline.

I’m currently stuck on spawning the actual controllers.  
When I try to use :

```
    AMyGraphPoint *tempObject = UEditorEngine::AddActor(GetWorld()->GetLevel(0), AMyGraphPoint,ObjTransform);

```

I keep getting : ‘AMyGraphPoint’: illegal use of this type as an expression.

AMyGraphPoint is :

```
UCLASS()
class AMyGraphPoint : public AActor
{
	GENERATED_UCLASS_BODY()

public:
	AMyGraphPoint();

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		USceneComponent *OurRoot;

	UFUNCTION(BlueprintCallable)
		void SetGraphPointPosition(FVector pos);
};

```

I’m not very experienced in c++ so there must be something obvious that I’m missing.

I’ve tried using SpawnActor and I end up at the same road block. There’s something I’m doing wrong in AMyGraphPoint.

Edit: I’m not trying to spawn a blueprint class. Everything is done in c++.

---

<div class="post-metadata">

**Author:** ![Bleeck](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bleeck](https://forums.unrealengine.com/u/Bleeck)\
**Post date:** [December 1, 2015, 8:50pm UTC](https://forums.unrealengine.com/t/how-to-spawn-an-actor-from-a-plugin/340246/2 "2015-12-01T20:50:11Z")

</div>

Figured it out.

```
			FVector const ObjLocation = FVector::ZeroVector;
			AMyGraphPoint* tempObject = (AMyGraphPoint*)GetWorld()->SpawnActor(AMyGraphPoint::StaticClass(),&ObjLocation);
```

---

<div class="post-metadata">

**Author:** ![vivek599](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vivek599](https://forums.unrealengine.com/u/vivek599)\
**Post date:** [February 7, 2022, 6:42am UTC](https://forums.unrealengine.com/t/how-to-spawn-an-actor-from-a-plugin/340246/3 "2022-02-07T06:42:25Z")

</div>

How did you get GetWorld() in plugnin
