Logical type game *SOLVED for now*

Hey ! Hello everyone :slight_smile:

I just started playing with this amazing program and I want to learn it as much as I can :smile:

Well… Since I’m new and inexperienced with Unity, I have some problem with its logic to work. I tried some tutorial, but I want to test something that I didn’t see anywhere as a game created with Unity 3D.

The project I want to do → A logic type game like “Neverhood”, “So blonde”, “Monkey Island” and games like that.

So I started trying to do some basic stuff that I’ll need in the project. The first one is the movement. And there is where I have my little problem of logic o.O

List of the “problems” and its page :

1) Movements ( A to B ) —> Page 1

PS : I’m very sorry if my English is a bit poor :S I’ll try my best to make my stuff clear and almost cute :stuck_out_tongue: ok nevermind for the cute part haha :wink: Well, thanks in advance for your help ! :smile:

1) Movements (A to B)
→ Multiple destinations

The “mechanic” I want → We have the main character, let name it Bob”… Well, in this project, he’ll have to move in a 3D worldspace in a cartoon design ( but its not important for now… ). There is the important thing. When the player will click on a specific object on the map, a lever, a crate, a window, a door or anything like this, he will walk to it and stop just before it.

The problem I have → I actually have the movement of the character from “pointA” to “pointB”, but the “pointB” is referenced by “force” in the script of my character. ( The scripts will be a bit down there ).

What I want → The thing I want is quite simple. I want to change the destination of Bob when I click on a new object in the scene.

Script of the main Character
File name : Linked.js

// The destination of the main character
var pointB : Transform;
var letMove = false ;
var pointA:Vector3 ;

function Update () {

	var controller : CharacterController = GetComponent(CharacterController);
	pointA = transform.position;
	var fwd = transform.TransformDirection (Vector3.forward);
		
   if (letMove) {
	  transform.LookAt(pointB);
	  if (Physics.Raycast (transform.position, fwd, 0.8)) {
		 letMove = false ;
	  }
	  transform.position = Vector3.Lerp(pointA, pointB.position, Time.deltaTime * 2);
   }
}

Script of a target “A cube here”
File name : cubePoint.js

// The script name in the main character
var linked : Linked; 

function OnMouseDown() {
   linked.letMove = !linked.letMove; 
}