Need small help with coord calculation.
#1

I'm not that good at playing around with coordinates so I need a small help here.

The thing is about the shop exit position. I have a command to create the shop, let's say, your character is facing at the door while creating the shop. The shop's entrance pickup now has the character's facing angle and position stored. I am checking the same coordinates to set the players' position when they exit the shop. I only managed to get the facing angle working as it should, by adding +180.0 to the pickup's rotation.

I wanted to set the player's position a little bit farther from the pickup but when I changed the X and Y's values, it's working in a weird way. Like, sometimes it sets the player's position to the right side, sometimes left and sometimes the player gets bugged inside the building, perhaps, it's because of every pickups not having the same rotation. How do I calculate the position to be set exactly in front of the pickup but a little bit far?

PHP код:
robshop_PlayerEnterExit(playeridshopidbool:is_exit) {
    new 
typeFloat:xFloat:yFloat:zFloat:aintworld;
    
    
type RobShop(shopidType);
    
= (is_exit) ? RobShop(shopidEntranceX) - 2.0 RobShopType(typeSpawnX);
    
= (is_exit) ? RobShop(shopidEntranceY) : RobShopType(typeSpawnY);
    
= (is_exit) ? RobShop(shopidEntranceZ) : RobShopType(typeSpawnZ);
    
= (is_exit) ? RobShop(shopidEntranceA) + 180.0 RobShopType(typeSpawnA);
    
    
int = (is_exit) ? RobShopType(typeInterior);
    
world = (is_exit) ? RobShop(shopidWorld);
    
    
SetPlayerPos(playeridxyz);
    
SetPlayerFacingAngle(playerida);
    
    
SetPlayerInterior(playeridint);
    
SetPlayerVirtualWorld(playeridworld);
    
SetCameraBehindPlayer(playerid);

If you question what are the SpawnX, SpawnY, SpawnZ and SpawnA are for, I used em to spawn the player inside upon entering since the shop interiors are separated by the virtual world, I didn't hesitate to calculate this either. Just have the spawn coordinates stored in the shop's table.

Sorry if my explanation is bad, that's all I could do.
Reply
#2

PHP код:
+= distance floatsin(-angledegrees);
+= distance floatcos(-angledegrees); 
Where distance is the number of meters you want to displace the player and angle is the facing angle away from the door.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
PHP код:
+= distance floatsin(-angledegrees);
+= distance floatcos(-angledegrees); 
Where distance is the number of meters you want to displace the player and angle is the facing angle away from the door.
Perfect! Took a while for me to figure this out but got it working. Thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)