Skip to content
TheChatArchiveThe Chat Archive
Coherecommand-a-03-2025· CohereHugging Face LMArena Human Preference 140K

local function OnCameraUpt() if activeCar and activeCar.PrimaryPart then if…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with DeepSeekdeepseek-v3-0324’s answer.
  1. User

    local function OnCameraUpt() if activeCar and activeCar.PrimaryPart then if activeCar:IsA("Model") and activeCar.PrimaryPart then local currentCarCFrame = activeCar.PrimaryPart.CFrame local carPosition = currentCarCFrame.Position

    		local x, cameraYawRad, z = currentCamera.CFrame:ToOrientation()
    
    		local newCarCFrame = CFrame.new(carPosition) * CFrame.Angles(0, cameraYawRad + math.rad(-90), 0)
    
    		activeCar:PivotTo(newCarCFrame)
    	end
    end
    

    end

    find a way for me to make the car face the camera direction with out ruining its positional movement

  2. Cohere Assistant

    To make the car face the camera direction without affecting its positional movement, you can modify the OnCameraUpt function to only adjust the car's orientation (rotation) based on the camera's yaw, while keeping its position intact. Here's the updated code:

    local function OnCameraUpt()
        if activeCar and activeCar.PrimaryPart then
            local currentCarCFrame = activeCar.PrimaryPart.CFrame
            local carPosition = currentCarCFrame.Position -- Store the current position
    
            local _, cameraYawRad, _ = currentCamera.CFrame:ToOrientation() -- Extract camera yaw
    
            -- Calculate the new orientation based on the camera's yaw
            local newOrientation = CFrame.Angles(0, cameraYawRad, 0)
            
            -- Combine the original position with the new orientation
            local newCarCFrame = CFrame.new(carPosition) * newOrientation
    
            activeCar:PivotTo(newCarCFrame) -- Apply the new CFrame
        end
    end
    

    Key Changes:

    1. Preserve Position:
      • carPosition stores the car's current position, ensuring it remains unchanged.
    2. Extract Camera Yaw:
      • Use currentCamera.CFrame:ToOrientation() to get the camera's yaw (Y rotation) only.
    3. Create New Orientation:
      • CFrame.Angles(0, cameraYawRad, 0) creates a rotation CFrame aligned with the camera's yaw.
    4. Combine Position and Orientation:
      • CFrame.new(carPosition) * newOrientation merges the original position with the new rotation.

    Why This Works:

    • Position Isolation: The car's position is explicitly preserved from its original CFrame.
    • Orientation Update: Only the rotation is updated to match the camera's yaw, ensuring the car faces the camera without moving.

    This approach ensures the car smoothly faces the camera while maintaining its current location in the world.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.