So im just messing about with character classes and player controller class.
Previously I was doing all my inputs in the character class. But I wanted to have a proper player controller and derive from the base character class for the AI characters.
So. Im after some pointers.
I have changed my character class around a bit and created a player controller class to control all the inputs n what not.
My baseCharacter class holds functionality for calculating health and energy and thats about it.
My player controller handles Input as well as two functions.
One is a ray trace which calculates if you can use an actor in the world, the other calculates the nearest actor of a particular type to use as a respawn point.
Im curious as to the best place to keep those functions. Should they exist in the character/pawn class or within the player controller.
Here is the function for getting a usable actor which is in the player controller
https://imgur.com/qBkoxIP
And here is how its called in the event graph
https://imgur.com/06clN5U
The problem is, after i kill and respawn the player the log is spammed with
Blueprint Runtime Error: Attempted to access Nox_BaseCharacter_C_0 via property BaseCharacterRef, but Nox_BaseCharacter_C_0 is pending kill from function: 'GetUsableActor' from node: LineTraceForObjects in graph: GetUsableActor in object: Nox_PlayerController with description: Attempted to access Nox_BaseCharacter_C_0 via property BaseCharacterRef, but Nox_BaseCharacter_C_0 is pending kill
Here is how I kill the character. This is within the base character class
https://imgur.com/jkr3oiY
The playerDied function at the end is an event which exists within the player controller class.
Which looks like this
https://imgur.com/vYxEI8I
And here is how I respawn the character. In the gamemode.
https://imgur.com/AgiPEQ5
Previously, just using a character class. This all worked a bit better. After respawning, the HUD reappeared and I didnt get the log spam from the usable actor.
Im just trying to find out if im going about this sort of behaviour in the right way.
Any help is very much appreciated.
Thanks all!
Previously I was doing all my inputs in the character class. But I wanted to have a proper player controller and derive from the base character class for the AI characters.
So. Im after some pointers.
I have changed my character class around a bit and created a player controller class to control all the inputs n what not.
My baseCharacter class holds functionality for calculating health and energy and thats about it.
My player controller handles Input as well as two functions.
One is a ray trace which calculates if you can use an actor in the world, the other calculates the nearest actor of a particular type to use as a respawn point.
Im curious as to the best place to keep those functions. Should they exist in the character/pawn class or within the player controller.
Here is the function for getting a usable actor which is in the player controller
https://imgur.com/qBkoxIP
And here is how its called in the event graph
https://imgur.com/06clN5U
The problem is, after i kill and respawn the player the log is spammed with
Blueprint Runtime Error: Attempted to access Nox_BaseCharacter_C_0 via property BaseCharacterRef, but Nox_BaseCharacter_C_0 is pending kill from function: 'GetUsableActor' from node: LineTraceForObjects in graph: GetUsableActor in object: Nox_PlayerController with description: Attempted to access Nox_BaseCharacter_C_0 via property BaseCharacterRef, but Nox_BaseCharacter_C_0 is pending kill
Here is how I kill the character. This is within the base character class
https://imgur.com/jkr3oiY
The playerDied function at the end is an event which exists within the player controller class.
Which looks like this
https://imgur.com/vYxEI8I
And here is how I respawn the character. In the gamemode.
https://imgur.com/AgiPEQ5
Previously, just using a character class. This all worked a bit better. After respawning, the HUD reappeared and I didnt get the log spam from the usable actor.
Im just trying to find out if im going about this sort of behaviour in the right way.
Any help is very much appreciated.
Thanks all!
Comment