#Stuff not moving(properly)
1 messages · Page 1 of 1 (latest)
k
where you declare hitPoint
if (Input.GetMouseButtonDown(1))
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask))
{
Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
Debug.Log("Did Hit");
hitPoint = hit.point;
Debug.Log(hitPoint);
Vector3.MoveTowards(player.transform.position = Vector3.MoveTowards(player, hitPoint, step));
}
else
{
Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.white);
Debug.Log("Did not Hit");
}```
thx
wait
Vector3.MoveTowards(player.transform.position = Vector3.MoveTowards(player, hitPoint, step));
that doesnt look right
this line seems weird
Vector3.MoveTowards(
you have to get rid of that
also you're only calling that line IF the player clicked mouse button AND if the raycast hit
yes
Vector3.MoveTowards(player.transform.position = player, hitPoint, step);
is that right?
so you have to put that line outside of the if statements into something like Update or FixedUpdate
player.transform.position = Vector3.MoveTowards(player.transform.position, hitPoint, step));
what do i have to do?
so change that weird line into
this
and then move that line after the if/else statement
can you send your update/fixedupdate functions?
ok
with line numbers, so it's easier to talk
wait you already have it kinda written
?
so put player.transform.position = Vector3.MoveTowards(player.transform.position, hitPoint, step)); this line right after line 19
so on line 20
yes
ik but when you use the grapple hook, grappling.IsGrappling() return true, right?
that's part of the other grappling hook
yes
that's a different function though
the Vector3.movetowards() will only call ONCE, when the player clicks the button
which will only move the player a fraction of a unit
So instead, we want to move the player towards the point of grapple, EVERY FRAME that the player uses the grappling hook
ok
that is the code for what i'm doing
why are lines 33&34 the same?
i'm not sure
ok
but line 33 will only get called once
which kinda doesn't work
well i guess if it moves to the location until you stop holding rmb, then it will be fine
it only does it once though
Instead of Input.GetMouseButtonDown use Input.GetMouseButton(1)