Posts by Dragonorb

    forget everything I've said before this is the fix for it!

    if you use the Steam VR Prefab do not remove any child objects just simply use the code or something like it.

    I was trying to turn the body which was the play area.... dont do that...

    I'm showing this code because there was no documentation on how to do this anywhere online. I was just messing with the overloads of the transform.Translate when I found this method.

    I Tried that but it did not work. HOWEVER! i did fix the problem a different way and it fixed another issue i was having at the same time. I took the camera out of the Steam VR prefab (even thought a previous post i said this didn't work). I created a Empty game object and called it head. Placed the camera in the empty game object and made a new script that moved the head along with the body and placed new script on the head game object. then i went back to the function that rotated the body and used the code below.

    How this salved two problem i will explain.

    1. taking the head out of the prefab meant that when the play area / player rotated the head did not try to turn with it keeping it in the direction it was looking with out spinning out of control.

    2. the code below takes the body transform local Euler angles into a new vector 3 were we keep the x and the z the same but the y matches the heads. this allows the body to turn pretty smoothly were the head it looking but only on the y axis.

    1. void RotateBodyByLookDirection()
    2. {
    3. transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, Head.transform.localEulerAngles.y, transform.localEulerAngles.z);
    4. }

    ive used the code below and it almost works well. when i turn to the right it speed is grate however, when i turn to the left it speeds up super fast. so im amusing that the turn buffer (smoothness) is only being applied to the y's positive direction and when it goes to the y's negative direction it speeds up.

    Anyone know how i might fix this issue?

    see code below.

    1. void RotateBodyByLookDirection()
    2. {
    3. transform.RotateAround(Head.transform.position, Vector3.up, Head.transform.localEulerAngles.y * turnBuffer);
    4. }

    you can not take the head out of the prefab the body will walk away form the head but will move in the head direction. if you change the head to be setup in the inspector instead of though code that is. I tried making 2 quaternion. One with Quaternion bodyRotation = new Quaternion(0, playerTransform.rotation.y, 0, 0) and the other One with Quaternion headRotation = new Quaternion(0, Head.transform.rotation.y, 0, 0). Then i tried to use playerTransform.rotation = Quaternion.Slerp(bodyRotation, headRotation, turnBuffer) however that just ended up turn the player -180 and then the player could only move forward and back and sided to sided. I want the body to only turn on the Y axis to match the heads rotation.

    well I think there was something weird with the navmesh.move function. it would not let my player body move with the head direction. i switched it to transform.Translate and it worked. however even with me trying to smooth it out its jumpy. i thiink its because the head is attached to the player so when the body moves its also trying to move the players head at the same time. however i dont know if i can breake the steam.VR prefab and it still track the head but i can try. Unless im smoothing the body to the head wrong.

    the head.transform.position is much worse then what 37 is. it makes the player go super fast and you cant turn your head to change directions (so it just goes in a straight line). Head.transform.rotaion += touchPadInput.x would need to be put as a new Quaternion to get the other vales. however that would not get me the forward direction. playerAgent.Move is a vector 3 so i have to form evertying around a vector3 some how. from what i can tell anyways.

    I have movement mostly working just with a slight problem. I want the player to be able to turn the direction the head it facing while being able to move side to side and backwords. im using the navMeshAgent for player movement area. so i got the touch pad to move the player around however there I could not turn around. so then i started working with getting the player to turn and move the direction the player was looking but now i cant move sided to side or backwards. i can now only move the direction the player is moving..... think i need to combined the two some how.

    its only when I add the touchPadInput += Head.transform.forward; that he play actually move where they are looking but then no side to side or back words movement.

    Items are a ScriptableObject that contains all item properties that i'm still adding to. I'm not adding straight to the inventory list. it has a Add and Remove function that checks if it has space to add the item. (Inventory script) (Item Script)

    your loop worked!!

    i didnt know you can search though the List of items content like that.

    look like i got learn more about lists and what i can do with them.

    Thank You Yin!!!

    well I tried it this way but i got an Array out of Range error. I really suck at loop statements.

    I have not written the check because i make sure i have the right amount of items in the inventory when craft the item. It will be there later i just want to make sure this works before adding more functionally. this code is be ran when the play clicks the UI button to craft a item. this looks similar to RuneScape Crafting System.

    the Inventory.instance.Add(itemToCraft.finalProduct) was out side the loop however when i clicked the UI button the item was not added after the item was removed. I then had to click the crafting button again then it added the finalproduct to the inventory.

    the code is removing and adding the right items. its just not removing all the required items.

    I will try to switch and check if the requiredItems are in the Inventory. Not sure if i just switch the position on what im looping thought. I still not sure how and when to use which type of loop.

    I am trying to create a crafting system and it is sort of working. However, I am having trouble looping though my inventory.

    in the code below there is a public CraftingItem itemToCraft. all this class has is a Public Item finalProduct and an Item array called requiredItems;

    so what im trying to do is loop though my inventory to see if the items match the required items then i want to remove the required items and added the final product which is the item i want to craft.

    however this only gets rid of one item not all the required item and put the finalProduct in my inventory.

    my understanding of loops are lacking can someone help with this. I feel I'm close but have been struggling for a day on this.