Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

I am making a constructing sport in unity and c#

I need to have the ability to scroll the display in all 4 instructions when in constructing mode.
In the meanwhile, I can rotate the digicam and scroll the display left and proper, however it doesn’t matter what rotation the digicam is oriented to, it all the time scrolls in the identical route. I.e. Beginning the sport the digicam pans, left, proper as meant. But when I rotate the digicam 90 levels, scrolling left now scrolls up and proper scrolls down.

I need the digicam to pan left, proper, up and down based mostly on the cameras rotation.
I nonetheless haven’t discovered learn how to pan up or down as this simply strikes the digicam up and down, so I’ve commented this out for now.

I attempted scrolling relative to the cameras rotation however that did not work. You possibly can see my makes an attempt within the replace operate.

Ive been googling to try to discover a answer however no luck. Ive connected a hyperlink to a video higher displaying my concern. https://www.loom.com/share/02f84b545cc44efbb1fe72be05e0631a

utilizing System.Collections.Generic;
utilizing UnityEngine;

public class CamFollowPlayerScript : MonoBehaviour
{
    //----------- This script rotates the cam in isometric veiw

    
    public GameObject participant; // declare participant gameobject
    public Vector3 spinCam; // declare vector 3 for the digicam
    public float camSpinSpeed; // declare float to carry the velocity of the digicam rotation
    public bool isCameraFollwingMouse;
    public Cursor mouseCurson;
    public float mSpeed; // Scale. Velocity of the motion
    public Digicam isoCam;

    public GameObject eastDirectrion;

    public Vector3 mRightDirection;// = 3.proper; // Course the digicam ought to transfer when on the proper edge
    public Vector3 mleftDirection;// = Vector3.left; // Course the digicam ought to transfer when on the proper edge
    public Vector3 mUpDirection;// = Vector3.up; // Course the digicam ought to transfer when on the proper edge
    public Vector3 mDownDirection;// = Vector3.down; // Course the digicam ought to transfer when on the proper edge

    personal void Begin()
    {
        mSpeed = 5;
        camSpinSpeed = 20f;
    }

    personal void Replace()
    {
       
        spinCam = new Vector3(Enter.GetAxis("VerticalIso"), Enter.GetAxis("HorizontalIso"), 0.0f); // spinCam is a brand new vector 3, taking the axis from the unity enter settings on the X and Y axis and 0 on the Z axis
        this.rework.Rotate(spinCam * camSpinSpeed * Time.deltaTime); // rotate the digicam utilizing the vector 3 from the spin cam, by the spinCamSpeed float by time.delta time. 

         mUpDirection = new Vector3(0,0,0); // Course the digicam ought to transfer when on the proper edge
         mDownDirection = new Vector3(0,0,0); // Course the digicam ought to transfer when on the proper edge
         mRightDirection = new Vector3(isoCam.rework.rotation.x, 0, isoCam.rework.rotation.z);
         mleftDirection = new Vector3(-isoCam.rework.rotation.x, 0, -isoCam.rework.rotation.z);

        if (Enter.GetKeyDown(KeyCode.M))
        {
            isCameraFollwingMouse = !isCameraFollwingMouse;
        }
    }

    void LateUpdate() // known as in spite of everything replace() strategies have been known as
    {
        if (!isCameraFollwingMouse)
        {
            rework.place = participant.rework.place;// 
        }

        if (isCameraFollwingMouse)
        {
            // Examine if on the proper edge
            if (Enter.mousePosition.x >= Display screen.width )
            {
                // Transfer the digicam
                rework.place += Vector3.proper * Time.deltaTime * mSpeed;
            }

            if (Enter.mousePosition.x <= 0)
            {
             // mm  // Transfer the digicam
               rework.place += Vector3.left * Time.deltaTime * mSpeed;
            }

            if (Enter.mousePosition.y >= Display screen.top)
            {
                // Transfer the digicam
               // rework.place += mUpDirection * Time.deltaTime * mSpeed;
            }

            if (Enter.mousePosition.y <= 0)
            {
                // mm  // Transfer the digicam
               // rework.place += mDownDirection * Time.deltaTime * mSpeed;
            }
        }
    }
}

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *