# How do I get pointer to PxScene in Nvidia PhysX API from Unreal Actor or component ?

**URL:** <https://forums.unrealengine.com/t/how-do-i-get-pointer-to-pxscene-in-nvidia-physx-api-from-unreal-actor-or-component/26277>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 2, 2015, 10:45pm UTC](https://forums.unrealengine.com/t/how-do-i-get-pointer-to-pxscene-in-nvidia-physx-api-from-unreal-actor-or-component/26277 "2015-04-02T22:45:27Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [April 4, 2015, 5:01pm UTC](https://forums.unrealengine.com/t/how-do-i-get-pointer-to-pxscene-in-nvidia-physx-api-from-unreal-actor-or-component/26277/3 "2015-04-04T17:01:23Z")

</div>

Code For you, Using UWorld\* To Get PhysX Scene

Dear Community,

**PhysX Wiki**

I’ve added to my PhysX Wiki showing you some code and additional #includes to use to get access to the PhysX Scene in a way where you can do low level multi-threaded PhysX coding!

**'s Wiki on PhysX Coding in UE4**

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

````auto

**PhysX + UE4 Code For You!**

Here's the code that you can use to get started in multi-thread friendly way, please see my higher post for more places to look for PhysX code in the UE4 code base.

```

//PhysX 
#include "PhysXIncludes.h"

//For the ptou conversions
#include "PhysicsPublic.h"	

//For Scene Locking using Epic's awesome helper macros like SCOPED_SCENE_READ_LOCK
#include "Runtime/Engine/Private/PhysicsEngine/PhysXSupport.h"

void SomeClass::SomeFunction(UWorld* World)
{
  check(World); 
  //if crash here world was not valid, needs to be investigated, did it come from a UObject?

  FPhysScene* PhysScene = World->GetPhysicsScene();
 
  // Scene Lock for Multi-Threading
  PxScene* SyncScene = PhysScene->GetPhysXScene(PST_Sync);
  SCOPED_SCENE_READ_LOCK(SyncScene);

  //now you can use the PhysX scene in multi-threaded fashion within this function context!
  // -
}

```

````

**Note on UWorld** \*

Any Actor can easily just call GetWorld() to get you the UWorld\* ptr

```auto

UWorld* World = YourActor->GetWorld();

```

UObjects can do the same but its not quite as reliable depending on the UObject

```auto

**Conclusion**

Have fun doing low level multi-threaded PhysX coding using the awesome Epic helper functions of PhysXSupport.h!

Enjoy!
```

---

_[View the full topic](https://forums.unrealengine.com/t/how-do-i-get-pointer-to-pxscene-in-nvidia-physx-api-from-unreal-actor-or-component/26277)._
