The cast is returning nullptr when casted from on component begin overlap (for character sphere collision). I’ve tried to verify it by class and it isn’t detecting the pickup item and hence returning nullptr.
Anybody has any idea what I’m doing wrong?
Can you show the code?
I found out later that the pickup item doesn’t exists on server or client that’s why the cast wasn’t detecting it but after that I’ve tried to make some changes in it and it’s still not detecting the pickup item
Here’s my code:
WB Inventory Slot:
WB Main:
Player Controller:
Player Base:
Actor Component:
Pickup Item Base:
If there is an overlap, you can cast, because something has to exist.
The cast probably fails, that’s the problem.
But I see no casting in your code. ( I also know nothing about MP, unfortunately )
I’ve used interfaces such as ‘Get Player Controller Ref’ to get player controller & ‘Get Player Ref’ to get player character instead of casting.
I’ve used event tick in pickup item base to check if the item exists or not but as it’s returning nothing that means it doesn’t exists that’s why it fails to detect
How are those get-x things implemented?
I created an interface event with return node to self, in case of GetPlayerRef it would be reference to BP_PlayerBase and in the blueprint then I’ll put reference to self in variable. I’ve followed the base from this skillshare course: https://skl.sh/3iK5Kji
Strangely enough, I was helping someone last night, who has also apparently followed this course…
I didn’t know it was multi-player when we started off, I know nothing about MP.
But: if your title is correct, and you’re trying to cast ‘item base’ to ‘character base’, that’s never going to work. There’s no relationship between them ( I assume ).
There’s an overlap. It worked when I created a Coin pickup but it doesn’t seem to work for this. I guess I might I’ve messed up somewhere else in the code as well
Ok, so you don’t actually mean cast from the pick to the player.
You probably have a collision box in the pickup? When some overlaps with it, you can try casting the ‘other actor’ pin to your player.
Can you show me that piece of code?
Hey so the code worked half way. Now the player is picking up item and the slot is displaying in the inventory but it’s not showing the image and the stack number. And I think that is because the code in player base is not working properly
Here’s the code:
I must admit I don’t get this
I mean, if it’s not the player, the code will continue with a null AC inventory comp.
Should there be a connection here?
And here?
The GetPlayerRef is similar to cast here made interface I’ve used it in my previous code and it has worked perfectly fine. And the other connections which you’ve mentioned are the same variable when are in the node.
The print strings which are in the Player Base aren’t working. Because only the first print node is working and not the for each loop