#Come here

1 messages · Page 1 of 1 (latest)

vagrant topaz
#

Type here

indigo garden
#

Thanks

vagrant topaz
#

Youve created a player obkect right

indigo garden
#

Yeah

vagrant topaz
#

Create a script in it

indigo garden
#

So i did

vagrant topaz
#

Ok can you type here the code by

indigo garden
#

i followed like 3 diffrent "Movement in 10 minutes" videos

vagrant topaz
#

`

indigo garden
#

and cs

vagrant topaz
#

Ye

#

Go ahead

indigo garden
#

more than 2k characters

#

wair

vagrant topaz
#

Not the whole code then

#

Just the problem

#

Although, there is no problem

#

Lemme explain this thing

indigo garden
#
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using Unity.VisualScripting;

public class Player : MonoBehaviour
{
    private bool JumpKeyWasPressed;
    private float HorizantalInput;
    private Rigidbody rigidbodyComponent;
    [SerializeField] private Transform GroundCheckTransform = null;
    [SerializeField] private LayerMask playerMask;
    private int SuperJumpsRemaining;
    public float playerSpeed;
    public float sprintSpeed = 4f;
    public float walkSpeed = 2f;
    public float mouseSensitivity = 2f;
    public float jumpHeight = 3f;
    private bool isMoving = false;
    private bool isSprinting = false;
    private float yRot;

    private Animator anim;
    private Rigidbody rigidBody;

    // Start is called before the first frame update
    void Start()
    {
        rigidbodyComponent = GetComponent<Rigidbody>();
        playerSpeed = walkSpeed;
        anim = GetComponent<Animator>();
        rigidBody = GetComponent<Rigidbody>();


    }
    
    // Update is called once per frame
    void Update()
    {
        
        if (Physics.OverlapSphere(GroundCheckTransform.position, 0.1f, playerMask).Length == 1)
        {
            return;
        }
        //Press the space bar to apply no locking to the Cursor
        if (Input.GetKey(KeyCode.Space))
            Cursor.lockState = CursorLockMode.Locked;

        // Check if space key is pressed down
        if (Input.GetKeyDown(KeyCode.Space))
        {
            JumpKeyWasPressed = true;
            float jumpPower = 5f;
            if (SuperJumpsRemaining > 0)
            {
                jumpPower *= 2;
                SuperJumpsRemaining--;
            }
            rigidbodyComponent.AddForce(Vector3.up * 5, ForceMode.VelocityChange);

            if (!Input.GetKeyDown(KeyCode.Space))
                rigidbodyComponent.AddForce(Vector3.zero, ForceMode.VelocityChange);
        }
        JumpKeyWasPressed = false;
    }

vagrant topaz
#

There is Input.GetAxis("Horizontal" or "Vertical")

#

W and s and up and down arrow keys are vertical

#

A d yata yata

indigo garden
#

I found a guy on YT that suggested

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerCam1: MonoBehaviour
{
    public float sensX;
    public float sensY;

    public Transform orientation;
    float xRotation;
    float yRotation;


    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;

    }

    private void Update()
    {
        float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
        float mouseY = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensY;

        yRotation += mouseX;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
        orientation.rotation = Quaternion.Euler(0, yRotation, 0);
    }
}```
vagrant topaz
#

add private infront float x and y Rotation

#

Ur making an fps game

#

hm

indigo garden
#

Yeah

#

I added the "Private" but still I can only look /

vagrant topaz
#

I think you can define the mouse rotations and stuff inside the Player script

indigo garden
#

left bottom to top right

vagrant topaz
#

And add the Camera's script in your Player script

vagrant topaz
#

Oh

#

Wait

indigo garden
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveCamera : MonoBehaviour
{

    public Transform cameraPosition;

    void Update()
    {
        transform.position = cameraPosition.position;
    }
}
vagrant topaz
#

What do you want to do and where we are rn

indigo garden
#

Cam script

#

I wanna walk and look around

vagrant topaz
#

[SerializeField] infron of transform camPosition

indigo garden
#

Yesterday I stayed up to 4am trying to fix it without any help and made a mess of maybe 5 diffrent codes and tried to make my own. That didnt really work out so I started over.

vagrant topaz
#

At void Start() or Awake()

indigo garden
vagrant topaz
#

Wait

indigo garden
vagrant topaz
#

cameraPosition = GetComponent<Transform>();

#

Thats how you get the transform component that is inside the object

#

Im in school rn. I can hrlp 50 minutes later. But others can help too

#

Its actually pretty simple

indigo garden
#

I refused to ask for help

#

but this shit starts to up my bloodpressure everytime i think i know what todo but actually dont

#

😄

vagrant topaz
#

so when you do public Transform cameraPosition, you define the cameraPosition being in the class of transform

#

@indigo garden

indigo garden
#

In Cam script?

vagrant topaz
#

Then you'll have to define cameraPosition as the Transform thing in the gameobject

#

Yeah

indigo garden
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveCamera : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        cameraPosition = GetComponent<Transform>();
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = cameraPosition.position;
    }
}
#

How the cam scripts looks rn

#

lemme run it

#

@vagrant topaz

vagrant topaz
#

Im on class rn

#

Hollup

indigo garden
#

take ur time bro

#

no rush

vagrant topaz
#

At Update() youll have to define the cameraPosition.position as...

#

Actually nothing

#

Cuz you gonna change it when the player turns

#

So in player script

#

At the top

#

Type

indigo garden
#

omfg

#

im retarted

vagrant topaz
#

[SerializeField]
Transform cameraPositionTransform

#

;

indigo garden
#

i removed cs public Transform cameraPosition;

#

by accident

vagrant topaz
#

Delete the script

indigo garden
#

cam script?

vagrant topaz
#

You can play with the camera by Player s script

#

It is its parent object right

#

The player

indigo garden
#

This is how youtube guy said to do it

vagrant topaz
#

That cameraholder is irrelevant right

indigo garden
#

Yesterday night i had it working but diffrently

vagrant topaz
#

I gotchu hollup

indigo garden
#

You still in school?

#

Able to vc?

#

i'll explain how I had it yesterday

vagrant topaz
#

40 mins later

#

Im gonna xome to vc

indigo garden
#

just mute

#

ow

vagrant topaz
#

In class

indigo garden
#

ahh

#

alr alr

vagrant topaz
#

If i wasnt, i would

#

I gotchu tho

indigo garden
#

Ill dm u in 40min

vagrant topaz
#

Im gonna teach it, so everytime you want to do it, you can do it urself

indigo garden
#

Love

vagrant topaz
#

😊

#

While im on class. Watch sum vids about first person stuff

#

There was this guy eho wanted to do the Pubg "q" "e" thing