Download

Project World to Screen not working/returning false?

I’m trying to use the “project world to screen” node (assuming it works like convert world location to screen location…) to check if an actor is in my screen. This is how I’m currently setting this up: http://i.imgur.com/quBmaWJ.png

This is in a multiplayer project. As of right now, its running on a server and playing with split screen. I think I’ve boiled it down to the pins, Screen position X and Y, that are returning 0.0 and I’m not sure why.

You use player controller with index 1. default one is 0. Maybe there is a problem?
Try to check IsValid for controller before use.

Ah, I forgot to say why I set it up this way. I’m trying to get player 2’s world location to screen location on player 1’s screen. Basically, I want to detect player 2’s actor on player 1’s screen.

Does Player 2 actually exist though?

If this is a multiplayer game taking place over internet or LAN - the only player controller that exists is the local one (for clients). If it’s split-screen, you’re ok.

Yeah, I’ve tested whether or not player 2 exists. I can print out both player controller reference’s: http://i.imgur.com/1xbfwlk.png

As of right now, I’m controlling player 1 with KBM and player 2 with xbox controller.

Well they both exist on the Server, but not on the Client. Only one Player Controller ever exists on the Client.

Therefore if your code is running Client-Side, it will fail.

If I recall correctly, return from ProjectWorldToScreen node is undefined if World Position is outside of camera space. There where several discussions on the forum regarding on screen indicators and how to properly implement them, using ProjectWorldToScreen is just not enough to make it work.

I think it is better for you to save both characters world location on server. Maybe in game mode/game instance. Then get it by every player as simple variable and use.

Why not use the actor and dot the locations and see if it’s within an angle of forward vector