Left Arrow Doesn't Log

It’s basically all in the title. I’m at the point where you set up the arrows and make the MoveStart function log a number when you click them. My right arrow is working fine. My left arrow doesn’t log anything. As far as I can tell, they’re identical. Does anyone have any ideas?

Hello Sarah,

Can you send us a screenshot of the script or paste it here?

using UnityEngine;
using System.Collections;

public class FloatXNudge : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
public void MoveStart(float xNudge){
	Debug.Log (xNudge);
}

}
I’m not awake in the morning and I misread the instructions which is why the script is called FloatXNudge. The event triggers on the left and right arrows call MoveStart when their arrow is clicked on.

1 Like

I don’t know what is the problem with that script since I haven`t done that class yet, I hope that someone more experienced can be more helpful

Thanks so much for taking a look at my script! If anything occurs to you later, please let me know. I may still be working on this.

Is the class you’re working on interesting?

1 Like

I`ll let you know if anything occours to me!

Yes, it is. I’m still at the Laser Defender class, but I’ve changed my game so much that it don’t even resemble the game that I was supposed to do in that class anymore, I’ll resume the classes as soon as I finish that game(within a month or two probably) :laughing:

Hi, I am also not at your class level yet, however looking at the script. Am I right in saying the method just takes input for both arrows on the x cord? So if the right works and left doesn’t I would suggest that maybe your unity input manager has been modified accidently or the triggers are different.

Anyway this may help

https://docs.unity3d.com/Manual/class-InputManager.html

1 Like

I dont know the structure of the other script which is accessing the public MoveStart(), would you mind pasting it here too Sarah?

Sorry for the delayed reply! Life’s a little crazy right now.
Thanks, Simon. I looked at the input manager. I don’t see anything wrong with it but I’ve never looked at it before. The arrows send in a fixed number when they’re clicked on. The left arrow’s supposed to send -5 and the right arrow 5 but right now they’re flipped because I was checking that the problem wasn’t something about the negative number.
Joao, I’m sorry but I can’t see the other script. It’s built in to Unity. I just add a component and tell it it’s supposed to trigger this function when this option on a dropdown list happens.

@Sarah_Hahn can you tell me which video to watch with this lesson in. If someone hasn’t got back to you by the time I see it tonight I’ll see if I can figure it out always good for learning :slight_smile:

Thank you so much! It’s video 195. Adding Arrows to Nudge Ball. The challenge is at about 4:43 - 6:01 with a gap where he’s doing something in the inspector. I had originally set things up a bit different from his answer but I’ve tried changing to, as far as I can tell, exactly match what he has and the left arrow still isn’t working.

1 Like

Ill take a look at it too

Hi @Sarah_Hahn and @Joao_Dalvi,

Ok so here is what I have done, after watching the video I appreciate I totally didn’t understand what you meant by arrows :slight_smile:

And this is what I think it is The Arrow Not Working Is Not A Raycast Target ??

If I play my recreation live then remove tick one of the inputs stops working.

Anyway I have re created it, and I think this is what you should do to separately, it will take 2 mins. If my first fix wasn’t it.

  1. Create a new project 2d is fine.

  2. Create Empty in the Hierarchy and call it MoveStart.

  3. Attach script to that object

using UnityEngine;
using System.Collections;

public class touch : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

public void MoveStart (float amount)
{
    Debug.Log("Moving " + amount);
}

}

  1. Add a UI Image Colour red (for clarity) call it left and add Event trigger drop in MoveStart object and call the method

  2. Same but blue

I had this working logging 5 and - 5 through touch.

The idea is you will test it independently from everything else first and maybe see a a problem if Raycast wasn’t it.

2 Likes

Thanks, Simon! I looked at the raycast and it’s checked. Then I created a separate scene, recreated my arrows, and started playing around. And I found something interesting! Both arrows work fine until I rotate my left arrow so that it’s facing left. I can’t see what that changes that would affect the clicking on it or the log but that’s what’s happening.

Wow ok, well at present I can’t see how that effects anything, but I will have another look tomorrow. Let me know if you solve it I will be very interested. I will keep my scene and DL the arrows next get a better feel for that. I hope by the time I wake in the morning you have found your answer. Your getting closer !! :slight_smile:

1 Like

I just found something else weird. I was rotating it in the y axis. If I rotate it in the z axis, it works fine. I’m not sure why but at least it works.
Thank you both very much for all your help!

1 Like

Great, I am glad it worked for you. Good luck with the rest of it.

1 Like

good job @Simon :grinning: