Question by
Lolzer82 · Oct 22, 2018 at 12:01 PM ·
normalized
Normalized not working (C#)
Hello! I am attempting to make a grappling hook-esque system for a small project I'm working on, but I've run into an issue where I'm trying to send the hook on a set speed but the speed still changes depending on where I click on the screen. Any idea what I'm doing wrong? Also, this is far from finished, so there's still plenty of things I've got left to implement.
public class ropeSystem : MonoBehaviour
{
public GameObject Hook;
public Camera cam;
public Vector2 target;
void Start()
{
}
void Update()
{
if(Input.GetButtonDown("Fire1"))
{
Vector3 click = cam.ScreenToWorldPoint(Input.mousePosition);
GameObject projectile = Instantiate(Hook, transform.position, Quaternion.identity) as GameObject;
projectile.GetComponent<Rigidbody2D>().AddForce((click-transform.position).normalized * 1);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How to access the coordinate x y after normalized it by another variable? 0 Answers
C# Invalid Normalized Color 1 Answer
Finding normalized value of divided number 2 Answers
Doubt about vector3 normalization direction. 1 Answer
Making my object move foward the same speed as up hill and down hill slope??? 1 Answer