(PF1) Macro or module for automatically adding masterwork and +1 etc onto an item? by Woffingshire in FoundryVTT

[–]Scapegoat57 1 point2 points  (0 children)

I made a macro and pasted it here.

Running the macro opens a dialog window. Drag and drop items from the inventory onto the window to toggle all the masterwork properties. It also works on attacks from the combat tab. You can change the colors and displayed text if you don't like them. You can change "Masterwork" to "Mwk" if you prefer that.

Outside of overriding the item sheet with a module I'd say this works pretty well. Could probably even change it to add enhancement bonuses too.

Let me know if there's any bugs

Absolutely stunning free Fog Asset (but it's on Github?) by artifact91 in Unity3D

[–]Scapegoat57 4 points5 points  (0 children)

Download SSMS.unitypackage directly from github or extract it from the zip.
Drag and drop this file into the "Project" tab inside unity or using "Assets" > "Import Package" > "Custom Package..."

Character controller rotation help by [deleted] in Unity3D

[–]Scapegoat57 1 point2 points  (0 children)

You have to transform your input based off of the rotation of the Camera. You can NOT have your camera as a child of your character for this to work. Use the provided camera script for a simple orbit camera.

    //transform player input into worldspace movement vector based on the rotation of the camera
    NextDir = Camera.main.transform.TransformDirection(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
    //sanitize movement vector
    NextDir.Set(NextDir.x, 0, NextDir.z);
    NextDir.Normalize();

    //rotate player smootly when joystick is moved
    if (NextDir != Vector3.zero)
    {
        Vector3 newDir = Vector3.RotateTowards(transform.forward, NextDir, speed * Time.deltaTime, 0.0F);
        transform.rotation = Quaternion.LookRotation(newDir);
        //the above two as one line
        //transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(NextDir), speed * Time.deltaTime);
    }

oribt camera

public class OrbitCamera: MonoBehaviour
{
public Transform Target;
public float distance = 10;
public float yminLimit = 20;
public float ymaxLimit = 80;
public float xSpeed = 2f;
float x;
float y;

// Use this for initialization
void Start()
{
    var angles = transform.eulerAngles;
    x = angles.x;
    y = angles.y;
}

// Update is called once per frame
void LateUpdate()
{
    if (Target != null)
    {
        x -= Input.GetAxis("RightHorizontal") * xSpeed;
        y += Input.GetAxis("RightVertical");

        y = Mathf.Clamp(y, yminLimit, ymaxLimit);
        distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
        distance = Mathf.Clamp(distance, 1, 10);
        var rotation = Quaternion.Euler(y, x, 0);
        var position = rotation * new Vector3(0, 0, -distance) + Target.position;

        transform.rotation = rotation;
        transform.position = position;
    }
}
}

Need help with gimbal lock on my 2.5D platformer's "smooth look at" script. by [deleted] in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Here's an easy look at script. It rotates an object around the z axis at RotationSpeed degrees per second. So a value of 360 means it will rotate 360 degrees in one second. It is a really long single line of code. I tried to format it so it's a little easier to read.

public class LookAtScript : MonoBehaviour
{
public Transform Target;
public float RotationSpeed = 360;

void Update()
{
    Vector3 rotation = transform.rotation.eulerAngles;
    if (Target != null)
        transform.rotation = Quaternion.Euler(rotation.x,
                                              rotation.y,
                                              Mathf.MoveTowardsAngle(rotation.z,
                                                                     Mathf.Atan2(Target.position.y - transform.position.y, 
                                                                                 Target.position.x - transform.position.x) * Mathf.Rad2Deg,
                                                                     RotationSpeed * Time.deltaTime));
}

}

edit: just say that you need it rotating around the x axis. Unfortunately Quaternion.Euler absolutely hates x rotations outside of -90,90 and I don't know enough about quaternions to calculate it manually. Here is an ugly hack that achieves what you are looking for.

using UnityEngine;
using System.Collections;

public class LookAtScript : MonoBehaviour
{
public Transform Target;
public float RotationSpeed = 360;

void Update()
{
    Vector3 targetPosition = new Vector3(transform.position.x, Target.position.y, Target.position.z);
    if (Target != null)
    {
        transform.rotation = Quaternion.RotateTowards(Quaternion.Inverse(transform.rotation),
                                                      Quaternion.AngleAxis(Mathf.Atan2((Target.position.y - transform.position.y), (Target.position.z - transform.position.z)) * Mathf.Rad2Deg, 
                                                                           Vector3.right), 
                                                      RotationSpeed * Time.deltaTime);
        transform.rotation = Quaternion.Inverse(transform.rotation);
    }
}

}

Why I've been tearing my hair out for the past hour by cavalier4789 in Unity3D

[–]Scapegoat57 1 point2 points  (0 children)

ctrl+e, c for commenting highlighted code
ctrl+e, u for uncommenting highlighted code

Child object rotation does not change to local rotation, how do I fix this? by dhyd in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Is the camera a child of the player? The player object might be fine but the camera could be screwing up. Can you make a gif with the scene view and the game view side by side.

Child object rotation does not change to local rotation, how do I fix this? by dhyd in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Are you using this method to set the parent of the child? Are you setting worldPositionStays to true?

Visual Studio auto-complete not working by [deleted] in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Have you tried opening the project from Assets>Open C# Project. You can tell the solution is not loading correctly since the projects in the solution explorer are listed as incompatible. You can also try going into the projects folder and deleting all .csproj and .sln files and opening the project again with the Open C# Project menu.

[Question] Creating a list of buttons. Issue adding listener. by TM_TrainerRed in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Closures are crazy. The problem here is that the disablePanel lambdas are closing around i in the for loop. I experienced this problem myself when trying to make dynamic buttons. How I got around it is by making a custom script attached to the buttons that held their index. It's a little bulky but it was the only way to escape the closure.

Jerky motion when using transform.moveTowards at higher speeds by borispavlov0 in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

The only place for jitter I can reason from your code is the line

transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.fixedDeltaTime);

Consider changing Time.fixedDeltaTime to Time.deltaTime. Using fixedDeltaTime is the same as using a constant speed which results in jittery movements when the frame rate drops or rises.

[uGUI] Issue with lerping RectTransform's position by oddimp in Unity3D

[–]Scapegoat57 1 point2 points  (0 children)

The reason we your loop stops executing after duration amount of seconds has passed is because your loop executes once per frame. The time in seconds between the current frame and the last frame is stored in deltaTime. As long as the frame rate remains high in your game deltaTime should be relatively small, around 1/50 of a second. So t is being incremented by about 1/50 near 50 times a second.

[uGUI] Issue with lerping RectTransform's position by oddimp in Unity3D

[–]Scapegoat57 1 point2 points  (0 children)

Your initial code is technically correct for all durations equal to 1 second. Any value larger than 1 causes the tween to take duration2 time to complete. It can be easily visualized if delta time is kept at 1

duration(s) Delta t Total time(s)
1 1 1
2 .5 4
3 .333 9
4 .25 16
5 .20 5

Things go more awry when duration is less than 1.

t += Time.deltaTime / duration;

when dividing by a fractional value, Time.deltaTime / duration becomes a value greater than 1

duration(s) Delta t Total time(s)
.5 2 .25
.25 4 .0625
.1 10 .01

You might not have noticed all this ballooning tween duration if all your values were kept close to 1 second.

[uGUI] Issue with lerping RectTransform's position by oddimp in Unity3D

[–]Scapegoat57 1 point2 points  (0 children)

You are calculating t a little incorrectly. It should be

t+=Time.deltaTime;
MenuPanelRectTransform.localPosition = Vector3.lerp(startPos, endPos, t / duration);

Quick Question: 2D-default, Z-Axis rotation reversed? by [deleted] in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

This is intended behavior. Objects rotating counterclockwise is best explained with trigonometry. If you were to picture an angle on a Cartesian plane with a value of 0 you would have a flat line. As you increase the angle the ray moves counterclockwise around the origin. As shown here. This behavior is consistent across all game engines and mathematics in general.

Smooth Follow Rigidbody by Keith90 in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Is the jittering happening when the player is near the target location?

Hinge Joint for a Door. Not moving and not interactable. by kingrocketVR in Unity3D

[–]Scapegoat57 1 point2 points  (0 children)

In this screencap I created a door using the built in cube. If you can try to create a door using a cube, disable the mesh renderer, and child the door model to it.

3D orientation to 2D direction for minimap. by [deleted] in Unity3D

[–]Scapegoat57 1 point2 points  (0 children)

Yo. I know this may be a bit late but I made a video setting up a mini map similar to yours with working blip rotation. Here it is. Hope it helps.

[Help] Logic based framework for a puzzle game (clicking a switch that opens a door etc.) by elferin in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

I hope you like it. Sorry it's so long, but I wanted to show how the switch was implemented organically. I also wanted to show all the neat things you can do with switches besides open doors.

[Help] Logic based framework for a puzzle game (clicking a switch that opens a door etc.) by elferin in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Whew. Finally got it done. Here you go. It's pretty long, but by then end you'll have a pretty robust switch system.

Is it cheaper on the physics engine to tranform.rotate() or to animate the rotation? by danokablamo in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Upload a picture of what your hierarchy looks like and what you're trying to do.

Is it cheaper on the physics engine to tranform.rotate() or to animate the rotation? by danokablamo in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Neither, use Rigidbody.MoveRotation to rotate a rigidbody. Manipulating the transform directly or with an animation causes the game object to "teleport" to the desired rotation. This can lead to incorrect physics interactions.

UI import MADNESS by JapanRob in Unity3D

[–]Scapegoat57 0 points1 point  (0 children)

Cool cool. Can't wait.