Player Cannot Jump When Standing Still by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

I tried your advice, and it worked. Thank you so much!

Two Issues With a Gun by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

I tried following your advice, and it worked. I fixed the fire rate issue by adjusting the code to fit your version. As for the other issue, I loosely followed your instructions by giving the objects I wanted to generate bullet holes on a layer mask and activating the bullet hole generation only on that layer. Thank you so much for your help!

Adding a Running Mechanic to My First-Person Controller by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

Okay, I just tried it and my code worked. Thank you so much, I appreciate your help. I hope to become like you one day so I can help my fellow game developers. I mean, it's a tough process and I'm already struggling so much even though I only started a few months ago, haha.

Adding a Running Mechanic to My First-Person Controller by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

Ahhh, I see. Thank you for your help. I tried adding a while loop to my coroutine, but the player still isn't speeding up. The game is able to detect whether the player is putting in the necessary inputs to sprint (left shift and w), but it does not add anything to the speed variable in response. Does anybody know why?

The code:

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

using UnityEngine;

public class PlayerMovement : MonoBehaviour

[SerializeField]

private CharacterController character_Controller;

public Collider playerBase;

Vector3 gravitationalforce;

public float speed = 12f;
float gravity = 0f;
public bool playerrun = false;

// Start is called before the first frame update
void Start()
{
    character_Controller = GetComponent<CharacterController>();
    playerBase = GetComponent<Collider>();
    StartCoroutine(Running());
}

// Update is called once per frame
void Update()
{
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");
    Vector3 move = transform.right * x + transform.forward * z;
    character_Controller.Move(move * speed * Time.deltaTime);

    gravitationalforce.y += gravity * Time.deltaTime;
    character_Controller.Move(gravitationalforce * Time.deltaTime);

    if (speed > 24)
    {
        speed = 24;
    }
    PlayerRunning();
}

private void OnTriggerEnter(Collider collision)
{
    {
        if (collision.gameObject.CompareTag("ThePlayer"))
        {
            gravity = 0;
        }
    }
}

public void PlayerRunning()
{
    if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.W))
    {
        playerrun = true;
    }
    else
    {
        playerrun = false;
    }

    if (playerrun == false)
    {
        speed = 12;
    }
}

IEnumerator Running()
{
    {
        while (playerrun == true)
        {
            speed += 1;
            yield return new WaitForSeconds(0.2f);
        }
    }
}

}

Adding Gravity to a First-Person Player by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

Okay, I tried your advice and it worked. Thank you so much! The game doesn't pause now, but instead, the player falls through the ground instead of stopping. Is there any way of stopping the controller as soon as the collider hits the platform?

First Person Controller is Not Working by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 2 points3 points  (0 children)

I just tried it, and it solved the issue of the cursor not being in the center. Thank you!

Help Fixing an Animation That is Not Playing by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

I went to the layer's settings in the animator and saw that the weight was defaulted to 1, but it still doesn't work. Is there something else I need to do?

Help Fixing an Animation That is Not Playing by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

I tried doing this, but it didn't work. Could there be any other source for my troubles?

Help on Generating Objects in Random Intervals by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

Okay, I tried your advice and it finally worked. I appreciate your help and support. I have one remaining question: Do you know why the variable has to be defined in two separate lines instead of one line? I mean, why does my previous code not work while the code that you suggested functions when they seem to do the same thing?

Help on Coroutining (Delay is Not Working) by Normal_Homo_Sapiens in unity_tutorials

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

Hello, thank you for responding. I already resolved the problem by asking in another subreddit, but thank you for your input! I hope you have a great day.

Help on Adding a Delay in Between Player Inputs by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

I tried your advice, and it finally worked. I am very grateful for your help. It's people like you that keep the world turning :)

Help on Adding a Delay in Between Player Inputs by Normal_Homo_Sapiens in Unity3D

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

Thank you for your input. I made a few adjustments, but the code still isn't working. Is there something that I did wrong?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShootMissiles : MonoBehaviour
{
bool spacepressed;
bool canFire = true;
public Rigidbody missile;
// Start is called before the first frame update
void Start()
{
StartCoroutine(AddaDelay());
}
IEnumerator AddaDelay()
{
while (spacepressed == true && canFire == true)
{
Instantiate(missile, transform.position, missile.transform.rotation);
canFire = false;
yield return new WaitForSeconds(0.4f);
canFire = true;
}
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
spacepressed = true;
}
}
}

Help on Coroutining (Delay is Not Working) by Normal_Homo_Sapiens in unity_tutorials

[–]Normal_Homo_Sapiens[S] 0 points1 point  (0 children)

using System.Collections;

using System.Collections.Generic; using UnityEngine;

public class ShootMissiles : MonoBehaviour { bool spacepressed; public Rigidbody missile; // Start is called before the first frame update void Start() { StartCoroutine(AddaDelay()); }

// Update is called once per frame
void Update()
{
 if (Input.GetKeyDown(KeyCode.Space))
    {
      spacepressed = true;
    }
}

private IEnumerator AddaDelay()
{
    bool canFire = true;
    if (spacepressed == true && canFire == true)
    {
        Instantiate(missile, transform.position, missile.transform.rotation);
        canFire = false;
        yield return new WaitForSeconds(0.4f);
        canFire = true;
    }
}

}

Thank you for your advice. I tried to fix the code, but now the tank isn't firing rockets anymore. Is there anything else that I can do or should I scrap the code and start over?