#Weapon should turn near my sprite but it turns somewhere else

1 messages · Page 1 of 1 (latest)

stuck magnet
#

I did everything same with this video but mine is not working https://youtu.be/DPqc7qYDtzM

In this video we will learn how to Aim a Melee Weapon at mouse pointer in Unity 2D. In the later video I will show you how to perform an attack and how to create enemies to fight with.

Make a Juicy 2d Shooter course:
https://courses.sunnyvalleystudio.com/p/make-a-juicy-2d-shooter-prototype-in-unity-2020

How to get input using the new input sys...

▶ Play video
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponParent : MonoBehaviour
{
    public Vector2 PointerPosition { get; set; }          

    private void Update()
    {
        transform.right = (PointerPosition-(Vector2)transform.position).normalized;

    }


}```
wispy inlet
#

What does "not working" mean? Use mp4 with videos so it gets embedded in discord and we dont have to download it

stuck magnet
#

oh sorry

#

I recorded with obs

glad turtle
#

People aren't going to download the mkv file

stuck magnet
#

Is there a way to change fike type

#

in obs

glad turtle
#

Should be an option in your settings.

#

Else convert it with handbrake or something.

stuck magnet
glad turtle
#

You'll still need to explain what's not working.

wispy inlet
#

Looks like the weapon parent's pivot is really messed up

stuck magnet
#

It should rotate near my sprite

wispy inlet
stuck magnet
#

I see

#

Changing it

wispy inlet
#

Look at the pivot/position of WeaponParent and its child, which I suppose is the weapon

stuck magnet
#

okay its now tuning near my character but circle is howw can I tell

#

getting bigger

#

when I walk

wispy inlet
#

WeaponParent wasnt a child of Sprite in the last video

stuck magnet
#

Oh I tried it before you replied

wispy inlet
#

Maybe just follow the tutorial again step by step

#

Does Weapon have any scripts on it? Does its position change in the inspector when that happens?

stuck magnet
#

Weapon doesnt have any scripts

#

Okay there was a child of weapon

#

about cinemachine(following camera)

#

but I think I created that accidentaly

#

when I deleted rigidbody and that child it started working properly