News about the Unity engine and project showcases from Reddit. Made possible with @reddit2telegram (@r_channels).
I made a mech controller prototype
https://redd.it/1bpchfe
@r_Unity3D
Dumb unity question
So I have a panel with items on it, and when you open the panel by clicking a button on my UI, when clicked for the first time during a play session, the panel is instantiated, and the items on it (UI wise) are displayed, however, my script that handles the items “decay rate” are UI wise in my inventoryUIManager.cs script and the update to update the decay rates every 1 second is elsewhere but mostly in my inventory manager, but when I close the panel (the inventory panel) the timers for the decay rate pause.
Is that because the panel is now inactive and the inventoryUImanager.cs controls some of this and is also now inactive ?
I would show the code but it’s late and I can update this post later, tomorrow but conceptually should all time based code be placed outside of panels? (Unity UI Canvas)?
Why does the time on the items work when the panel is active, but freeze / pause when the panel is closed (visually display set to false?, yet the panel object itself is still in the hierarchy and in the scene it’s just switched off visually.
I feel dumb for not understanding this simple principle.
https://redd.it/1bpiopi
@r_Unity3D
How can I make this texture more seamless?
https://redd.it/1bpfog3
@r_Unity3D
We're a small team developing a precision platformer game. Help us with your feedback!
https://redd.it/1bpc9n6
@r_Unity3D
Holding a key wont keep the movement.
Im triying the input system for the first time, moving a simple script for a 2d character. Usually i just, get the input getAxis for this but since im triying this, why is it that the raycast (raycast im only needing cause it loses speed getting uphill cause, i guess its not keeping the speed unless i keep tapping) is only firing when I tap or release the key instead of when holding?
Its happening the same with the shooting script making automatic weapons imposible, like, could use a coroutine but idk if theres some way to fix this built in.
public void Move(InputAction.CallbackContext callbackContext)
{
Vector2 input = callbackContext.ReadValue<Vector2>();
if (callbackContext.started || callbackContext.performed)
{
horizontalVelocity = input.x speed;
if (input.x > 0 && !m_FacingRight)
{
Flip();
}
else if (input.x < 0 && m_FacingRight)
{
Flip();
}
}
Vector2 raycastDirection = (Vector2)(transform.right - transform.up).normalized;
if (callbackContext.started || callbackContext.performed)
{
RaycastHit2D hitForward = Physics2D.Raycast(transform.position, raycastDirection, raycastDistance, groundLayer);
if (hitForward.collider != null)
{
float slopeAngle = Vector2.Angle(hitForward.normal, Vector2.up);
float complementaryAngle = 90f - slopeAngle;
horizontalVelocity /= Mathf.Cos(slopeAngle Mathf.Deg2Rad);
Debug.Log("Im speed");
}
}
rb.velocity = new Vector2(horizontalVelocity, rb.velocity.y);
if (callbackContext.canceled)
{
horizontalVelocity = 0f;
rb.velocity = new Vector2(0f, rb.velocity.y);
}
}
​
https://redd.it/1bpar1e
@r_Unity3D
Why is my vector so choppy?
https://imgur.com/a/swy71uW
If someone could guide me through the import settings or anything I should change id be grateful.
https://redd.it/1bp84uw
@r_Unity3D
Having issues with Unity and Android keyboards default input field UI
https://redd.it/1bp2ptr
@r_Unity3D
Feedback : Outline on vs Outline off?
https://redd.it/1bozg5q
@r_Unity3D
Give comments on the location in general
https://redd.it/1bowq5r
@r_Unity3D
Finally got my origin rebasing working!
https://redd.it/1bov04y
@r_Unity3D
My chunky pixel-art game is finally out on Steam! DUCK's most terrible day, built using Unity
https://preview.redd.it/yquf07awbrqc1.jpg?width=896&format=pjpg&auto=webp&s=604f77d7de323e02b121d76230700d595ce08da2
https://preview.redd.it/jduflxfubrqc1.jpg?width=896&format=pjpg&auto=webp&s=371dc714696b2486909fafbb80d4f340e4aa6f60
It took me a lot longer than expected but it's finally done and I'm pretty proud of it. Hope you can check it out!
https://store.steampowered.com/app/1980700/DUCKs\_most\_terrible\_day/
https://redd.it/1bolo4l
@r_Unity3D
Rigidbody2D's Velocity is zero but Object still moves
hey , i'm kinda new to programming and i faced a problem with my script , my Rigidbody2D's Velocity is always 0 , it's supposed to be facingRight =1 or -facingRight=-1 (from another script) but here its zero even if if still moves , here is the script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DamagedState : EnemyBaseState
{
public float KBForce;
public Vector2 KBAngle;
private float stunTime = 1;
private bool isStunned;
public DamagedState(Enemy enemy, string animationName) : base(enemy, animationName)
{
}
public override void Enter()
{
base.Enter();
ApplyKnockback();
}
public override void Exit()
{
base.Exit();
}
public override void LogicUpdate()
{
base.LogicUpdate();
if(isStunned)
{
if (Time.time > enemy.stateTime + stunTime)
{
isStunned = false;
Debug.Log("Enemy velocity = " + enemy.rb.velocity.x);
int forceDirection = enemy.rb.velocity.x > 0 ? 1 : -1;
if(enemy.facingRight != forceDirection)
enemy.Rotate();
enemy.SwitchState(enemy.chargeState);
}
}
}
public override void AnimationFinishedTrigger()
{
base.AnimationFinishedTrigger();
enemy.rb.velocity = new Vector2(enemy.rb.velocity.x, -enemy.rb.velocity.y);
isStunned = true;
}
private void ApplyKnockback()
{
enemy.rb.velocity = KBAngle * KBForce;
}
}
​
https://redd.it/1bohx9t
@r_Unity3D
Help with Unity/Visual Studios
When i open a C Sharp file it opens visual studio.But after that there is like no console or space to code in. How can i fix this
https://redd.it/1bogzef
@r_Unity3D
Hello everyone, we've brought a new update to our game Swarm Grinder, which has been in early access for a while now. With this update, all UI/UX in the game has changed, new upgrades and gadgets have been added (YOU CAN NOW DASH!), and we would love for you to try it out and give us feedback :)
https://redd.it/1bodvec
@r_Unity3D
Why isn't my character dashing?
public class MovementController : MonoBehaviour
{
rb = GetComponent<Rigidbody2D>();
public float dashForce = 10.0f;
public Vector2 moveInput = Vector2.zero;
void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
if (!animationState.stateLock)
{
rb.velocity = moveInput movementSpeed;
}
else
{
rb.velocity = Vector2.zero;
}
}
private void OnDash()
{
if (moveInput.magnitude > 0)
{
Debug.Log("Dashing");
Vector2 dashDirection = moveInput.normalized;
rb.AddForce(dashDirection dashForce, ForceMode2D.Impulse);
}
}
}
​
​
RigidBody configuration
Dashing is printed to the console, so I know that the function is being called. But it seems like no force is being added to the player? Maybe I'm missing something stupid but not entirely sure the issue here.
​
I'm using an InputActions map set to call the OnDash function when spacebar is pressed. I know it isn't an issue to do with the function being called
https://redd.it/1bpgocr
@r_Unity3D
how do i call/use an int variable from another script?
i know its a small issue, but iv searched it up but those methods do not work for me.
https://codeshare.io/64VO1Y feel free to edit it.
this is the value im trying to take from another script:
public int playerPhysicalDamage;
​
https://preview.redd.it/lho13shdryqc1.png?width=486&format=png&auto=webp&s=b990d57cca17ea29befa801b63251cc24a05a685
https://redd.it/1bpgprh
@r_Unity3D
Look of my new Cowboy game. This is the first time i show something
https://youtu.be/uO8DKUbPUNQ
https://redd.it/1bpcdl3
@r_Unity3D
We now have water depth detection in the game; characters will raise their hands to avoid getting wet, and deeper water levels will slow them down.
https://redd.it/1bp7b8i
@r_Unity3D
Worms like destructible terrain
Hi there , I'm working on a mini game with tanks and I would like to make a worms like destructible terrain .
what's the best approach to implement and code this type of terrain?
https://redd.it/1bp9hnb
@r_Unity3D
Drag and Drop Method Help
Heya people! (Disclaimer: still learning from tutorials) I would just like to know how can I modify the following scripts so that player can drag any of the options in the slot (and it will stay there first regardless if right or wrong) and the checking - if it has the same id - will only happen upon clicking the green button. If it has the same id, then the panel will close and I'll call some method of mine. If it's wrong, then the ResetPosition will be called.
https://preview.redd.it/c3j2g2kfcwqc1.png?width=1920&format=png&auto=webp&s=3bd5778bad31959ff46e6d082829ef619de56079
>> CS for the Options<<
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class DragAndDrop : MonoBehaviour, IPointerDownHandler, IBeginDragHandler, IEndDragHandler, IDragHandler
{
private RectTransform rectTrans;
public Canvas myCanvas;
private CanvasGroup canvasGroup;
public int id;
private Vector2 initPos;
private void Start()
{
rectTrans = GetComponent<RectTransform>();
canvasGroup = GetComponent<CanvasGroup>();
initPos = transform.position;
}
public void OnBeginDrag(PointerEventData eventData)
{
canvasGroup.blocksRaycasts = false;
}
public void OnDrag(PointerEventData eventData)
{
rectTrans.anchoredPosition += eventData.delta/ myCanvas.scaleFactor;
}
public void OnEndDrag(PointerEventData eventData)
{
canvasGroup.blocksRaycasts = true;
}
public void OnPointerDown(PointerEventData eventData)
{
}
public void ResetPosition()
{
transform.position = initPos;
}
}
>> CS for the Slot<<
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class SlotScript : MonoBehaviour, IDropHandler
{
public int id;
public void OnDrop(PointerEventData eventData)
{
if (eventData.pointerDrag != null)
{
if (eventData.pointerDrag.GetComponent<DragAndDrop>().id == id)
{
Debug.Log("Correct");
eventData.pointerDrag.GetComponent<RectTransform>().anchoredPosition = this.GetComponent<RectTransform>().anchoredPosition;
}
else
{
Debug.Log("Wrong");
eventData.pointerDrag.GetComponent<DragAndDrop>().ResetPosition();
}
}
}
}
https://redd.it/1bp4viq
@r_Unity3D
NEED HELP DESIGNING 2D POINT & CLICK GAME CHARACTERS
I have started working on a personal project. I am building a 2D point and click game. I need help on building the characters (a lot of them) the characters are my friends and I need to cartoonise them, and add animations of all sorts. Please provide any resources/website/references that would be useful.
I am using Adventure Creator in unity. Just can't figure out a way to add characters. Can't find any youtube videos that will help me with this problem. Most of them seem to have their character assets including animations (how will they look when they move) already downloaded and I cant find it anywhere.
https://redd.it/1bp2fwq
@r_Unity3D
i made track wheel, with no physics use, UV Texture animation and raycast only
https://redd.it/1boyxgc
@r_Unity3D
My new 2D skateboarding arcade game out now with a launch 75% off!!
https://youtu.be/2XPtPVkaGI8?feature=shared
https://redd.it/1boxip5
@r_Unity3D
A runaway weekend project, to rework a trusty tool, evolved into a completely worked out asset. Now on the asset store!
https://redd.it/1bo98w3
@r_Unity3D
(WIP) This is CraftAway, our university capstone project that is a top down 2D survival craft game inspired off of Stardew Valley and Terraria. What you think?
https://jalagon.itch.io/craftaway
https://redd.it/1bolo3i
@r_Unity3D
Added items for our russian roulette style game
https://redd.it/1bom084
@r_Unity3D
Rigidbody gravity problems
Hey all,
I have a problem regarding the gravity effect on my player character. I want to make him more dynamic, so falling faster and jumping faster. However, I can't make him fall faster or slower, even though I have played with the gravity setting on a rigidbody. Yes, one of my scripts changes the gravity setting on the rigidbody, but I have been checking the value as I played and different gravity values made no difference. Even changing the script didn't help.
Please help me if you can, I am truly lost on this one. Thank you
Edit: Noticed that the gravity setting on a rigidbody doesn't affect anything. No ragdolls, no movable boxes, nothing. Do I have to turn the gravity on or something? Sorry if this is a dumb question :D
https://redd.it/1boiaan
@r_Unity3D
UI: Light theme or dark theme? Which do you prefer? (been staring myself blind trying to decide)
https://redd.it/1boaagc
@r_Unity3D
Retro Dithering Post Effect [Git]
https://redd.it/1bobrej
@r_Unity3D