- Home /
Please HELP: ¿How can i made a drag and drop quiz?, i got some problems whit my scripts, like connecting the drag and drop function whit the buttons
I'm working on a 2D drag and drop quiz, the idea is that the icons on the pickup, upon contacting the trailer, give the correct answer, but i can't use the drag and drop script i made.
¿How can i drop and destroy the answer whit another object?
And, ¿how can i change the question, once it was answer?
//THIS IS MY GAME MANAGER
using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; using UnityEngine.UI;
public class GameManager : MonoBehaviour {
public TestQuestions [] questions;
private static List <TestQuestions> unAnsweredQuestions;
private TestQuestions currentQuestion;
[SerializeField]
private Text factText;
void Start(){
if (unAnsweredQuestions == null || unAnsweredQuestions.Count == 0){
unAnsweredQuestions = questions.ToList<TestQuestions>();
}
SetCurrentQuestion ();
/*Debug.Log (currentQuestion.fact + " is " + currentQuestion.isTrue);*/
}
void SetCurrentQuestion () {
int randomQuestionIndex = Random.Range (0, unAnsweredQuestions.Count);
currentQuestion = unAnsweredQuestions [randomQuestionIndex];
factText.text = currentQuestion.fact;
unAnsweredQuestions.RemoveAt (randomQuestionIndex);
}
public void UserSelectTrue (){
if (currentQuestion.isTrue) {
Debug.Log ("Correct");
} else {
Debug.Log ("Wrong");
}
}
public void UserSelectFalse (){
if (!currentQuestion.isTrue) {
Debug.Log ("Correct");
} else {
Debug.Log ("Wrong");
}
}
}
//AND THIS IS MY DRAG AND DROP SCRIPT
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Icons : MonoBehaviour { private Vector3 screenpoint;
void OnMouseDown(){
screenpoint = Camera.main.WorldToScreenPoint (gameObject.transform.position);
}
void OnMouseDrag (){
Vector3 currentScreenPoint = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenpoint.z);
Vector3 currentPos = Camera.main.ScreenToWorldPoint (currentScreenPoint);
transform.position = currentPos;
}
}
Your answer
Follow this Question
Related Questions
why is one side of collider behaving different than the other 2 Answers
show different textures when trigged entered thrice 2 Answers
How can i make different OnTriggerEnter actions into one Script? 2 Answers
Does OnTriggerStay ignore layers? 1 Answer
How to check which colliders that collision with some object ? 3 Answers