Hi - i know there are several questions like this, but none of them have a conclusive answer, and the only one that i could see and answer to has a broken link, in french, so i can’t see it:
anyway, I have a 2D sprite based game, where you click on the objects you want to choose from the HUD and they spawn in the play area, I have a drag rigid body script on them and it works fine, no problems.
However, i now think it would be better if the drag rigid body script worked in increments, i would have a grid on the background, and the drag wouldn’t be smooth, but would snap into the positions, each equally separated.
One way i could think of would be to put empty game objects on each point with a trigger area, and add a script on each trigger to say:
function OnTriggerEnter(){
draggedRigidbody.transform.position = this.transform.position
}
etc,
BUT i think this is extremely complicated as every level will have a different shaped grid, and i don’t want to have 30 triggers with scripts and have to set them up each level… would there be a better way to go about this?
thanks in advance, by the way if there are any code samples posted, could they be in JS please… still need to get round to start programming in C